Swipe Gesture Interrupts Uislider Control in iOS 13, But Not Previous iOS Versions

Gesture problem: UISwipeGestureRecognizer + UISlider

The simplest way to handle this is probably to prevent the gesture recognizer from seeing touches on your slider. You can do that by setting yourself as the delegate, and then implementing

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if ([touch.view isKindOfClass:[UISlider class]]) {
// prevent recognizing touches on the slider
return NO;
}
return YES;
}

If this doesn't work, it's possible the slider actually has subviews that receive the touch, so you could walk up the superview chain, testing each view along the way.

How to prevent a Cell from swiping when the UISlider inside of it is swiped

Got the answer from here which got the answer from here:

override init(frame: CGRect) {
super.init(frame: frame)

let panGesture = UIPanGestureRecognizer(target: nil, action:nil)
panGesture.cancelsTouchesInView = false
slider.addGestureRecognizer(panGesture)
}

UIControl tracking and iOS 13 presentation style cards not working together

Had to ask Apple about this, and they recommended the following solution, which worked:

if (@available(iOS 13.0, *)) {

for (UIGestureRecognizer *gestureRecognizer in self.navigationController.presentationController.presentedView.gestureRecognizers) {
gestureRecognizer.enabled = NO;
}

}

UISlider in UITableView - Movement issue

I've already solved it. It was issue with UIPanGestureRecognizer. The code:

- (IBAction)panGesture:(UIPanGestureRecognizer *)recognizer {
if ([recognizer.view isKindOfClass:[UISlider class]] || self.movieViewController) {
return;
}

if (recognizer.state == UIGestureRecognizerStateBegan) {
startLocation = [recognizer locationInView:self.view];

if (startLocation.x < 25) {
[self.menuContainerViewController reloadData];
[self hideBubble];
}
}

if (isMenuShown) {
if (startLocation.x > self.view.frame.size.width - 25) {
CGPoint stopLocation = [recognizer locationInView:self.view];
CGFloat distance = -self.view.frame.size.width + stopLocation.x;
[self movementAnimation:distance];
}
}
else {
if (startLocation.x < 25) {
CGPoint stopLocation = [recognizer locationInView:self.view];
CGFloat distance = -self.view.frame.size.width + stopLocation.x;
[self movementAnimation:distance];
}
}

if (recognizer.state == UIGestureRecognizerStateEnded) {
CGRect frame = self.menuContainerViewController.view.frame;

if (frame.origin.x + frame.size.width > self.view.frame.size.width / 2) {
[self slideInAnimation];
}
else {
[self slideOutAnimation];
}
}
}

And I added into my UIViewController:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if ([touch.view isKindOfClass:[UISlider class]]) {
return NO;
}
return YES;
}

Now it works like a boss!

resizableImageWithCapInsets on UISlider gets distorted in iOS 6 and up

Solved the problem like this:

if (iosVersion < 6.0){
rightStretchImage = [newImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, newImage.size.width - 2, 0, 0)];
}else{
rightStretchImage = [newImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, newImage.size.width - 2, 0, 0) resizingMode:UIImageResizingModeStretch];
}


Related Topics



Leave a reply



Submit