UIPanGestureRecognizer sometimes not working on iOS 7

后端 未结 2 390
甜味超标
甜味超标 2020-12-28 11:16

I\'m getting intermittent reports from users on iOS 7 saying that the UIPanGestureRecognizer stops working on certain views every once in a while. They\'re supp

相关标签:
2条回答
  • 2020-12-28 12:02

    Why would you return NO in gesture recognizer just because on gestureRecognizerShouldBegin: the movement is only vertical? Since it's gesture made by user with his finger (and not made by a machine), there will always be some randomness in it's movement due to inaccuracy of moving finger. gestureRecognizerShouldBegin: will be called just after user touches the screen and the translation you get might be just a few pixels. Your recognizer will fail if user i.e. when putting his finger on screen moves it 2 pixels up, even if he then moves it 200 pixels to the right. This shouldn't cause the gesture recognizer to be permanently disabled but you should look into it as well, since it might confuse users when their gestures are not recognized for seemingly no reason.

    0 讨论(0)
  • 2020-12-28 12:03

    I think I finally solved this issue. Apparently iOS 7 handles gestures in subviews differently than it did in iOS 6 and earlier. To handle this, Apple implemented a new delegate:

    (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
    

    If you return YES, that should get your gesture recognizer to work. I've implemented it and haven't had any issues so far (though admittedly this was a rare bug that I could never reliably reproduce, so it's possible that it just hasn't recurred yet).

    For more information, see https://stackoverflow.com/a/19892166/1593765.

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