滑动手势会中断iOS 13中的UISlider控件,但不会中断以前的iOS版本 [英] Swipe gesture interrupts UISlider control in iOS 13, but not previous iOS versions
问题描述
注意:这是iOS 13 Beta,但也可能会在明天正式发布.
Note: This is the iOS 13 beta, but also could apply to the official release tomorrow.
更新2:我用一个较大的缩略图替换了它,但仍然遇到问题.
Update 2: I replaced it with a larger thumb image, and I'm still having a problem.
更新:如果我非常精确地触摸滑块上的拇指,它似乎仍然可以连续控制.但是为什么会改变这种情况,我如何使其像以前一样进行控制?
Update: It looks like it still controls continuously if I'm super precise about touching the thumb on the slider. But why is this changed, and how can I make it control like before?
我在视图中添加了滑动手势识别器:
I have a swipe gesture recognizer added to my view:
let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture))
swipeRight.direction = UISwipeGestureRecognizer.Direction.right
self.view.addGestureRecognizer(swipeRight)
稍后,我将UISlider添加到同一视图:
Later on, I add a UISlider to the same view:
let slider = UISlider()
let sliderLength:CGFloat = 175
slider.frame = CGRect(x:0,
y:CGFloat(customHeight) - 35,
width:sliderLength,
height:35)
slider.minimumValue = -1.2
slider.maximumValue = 0.6
slider.setValue(Float(snowSliderValAdder), animated: false)
slider.addTarget(self, action: #selector(self.updateSnowSliderValue(_:)), for: .valueChanged)
view.addSubview(slider)
以前可以正常工作的东西,现在在iOS 13中表现不佳.如果我将滑块缓慢移动,则可以移动它的拇指,但是如果进行任何滑动动作,则滑块上的拇指会停止移动,并且手势被触发.我该如何阻止这种情况的发生?
What used to work fine, now behaves poorly in iOS 13. I can move the thumb on the slider if I move it very slowly, but if I do any kind of a swiping motion, the thumb on the slider stops moving and the gesture is triggered. How can I stop this from happening?
推荐答案
我遇到了相同的问题,并通过执行以下操作设法解决了这个问题:
I had the same issue and managed to resolve it by doing the following:
向您的滑块添加一个不执行任何操作的panGesture,并将其cancelsTouchesInView属性设置为false.
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.
这篇关于滑动手势会中断iOS 13中的UISlider控件,但不会中断以前的iOS版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!