Swipe gesture interrupts UISlider control in iOS 13, but not previous iOS versions

前端 未结 4 1025
感情败类
感情败类 2021-01-19 05:37

Note: This is the iOS 13 beta, but also could apply to the official release tomorrow.

Update 2: I replaced it with a larger thumb

相关标签:
4条回答
  • 2021-01-19 06:21

    SWIFT 5

    The Problem can be solve using delegate method of gesturerecognizer as below

    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
        if touch.view?.isKind(of: UISlider.self) ?? false {
            return false
        } else {
            return true
        }
    }
    
    0 讨论(0)
  • 2021-01-19 06:24

    What I did was use a gestureRecognizer function to stop any gestures if a touch was detected on my UISliders. Make sure to add UIGestureRecognizerDelegate and set the UISwipeGestureRecognizer's delegate to self.

    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
    
       if touch.view == self.view.viewWithTag(viewTags.MySlider.rawValue) {
            return false
       }
       else if touch.view == self.view.viewWithTag(viewTags.AnotherSlider.rawValue) {
            return false
       }
    
       return true
    }
    
    0 讨论(0)
  • 2021-01-19 06:25

    I tried to find something during the last hour. It looks like the swipe gesture recognizer as interferance with UISlider.

    The problem appears only if you are using right/left direction. Perhaps you should wait before update your app or change your UI to use the up/down swipe gesture.

    At this time the slider works normally if you wait a bit before you move your finger. Hoping Apple will fix it quickly.

    0 讨论(0)
  • 2021-01-19 06:32

    I had the same issue and managed to resolve it by doing the following:

    Add a panGesture ,that does nothing, to your sliders and set their cancelsTouchesInView propery to false.

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

    Now your sliders should slide like a knife cutting a butter with no swipe interruption.

    0 讨论(0)
提交回复
热议问题