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
How to Avoid Duplicate Key Error in Swift When Iterating Over a Dictionary
Cast Any to Float Always Fails in Swift4.1
Dynamic Datasource/Delegates for Uitableview in Swift
Convert [(Key: String, Value: String)] in [String:String]
How to Use View Controller (Calendarkit) in Swiftui Application
Xcode: Using Custom Fonts Inside Dynamic Framework
Swift 3: Int Is Not Convertible to Bool in Bitwise Operation
Inferred to Have Type 'Anyclass', Which May Be Unexpected
iOS Swift - Uitableviewcell Custom Subclass Not Displaying Content
Swift 2, Protocol Extensions & Respondstoselector
Swift: Accessing Computed Property Through Pointer
Xcode 9 Fails to Build Swift 4 Project with Pod
Opening Import File for Module 'Swift': Not a Directory
Error: Extraneous Argument Label 'No1:' in Call
Why Is Casting a Struct to Anyobject Not a Compile Error in Swift