UISwipeGestureRecognizer not firing

2019-07-23 12:24发布

I have a UISwipeGestureRecognizer setup in IB linked to my view like so:

enter image description here

Extremely trivial, done it a million times. However this time it never fires >:|

Here is my method that should be called when a user swipes.

enter image description here

However this never gets called.

  • No it's not accidentally added to a subview
  • Yes the Pan gesture works perfectly.

I have another view setup almost exactly the same as this that works fine. Any ideas?

1条回答
Animai°情兽
2楼-- · 2019-07-23 12:50

Try this delegate Method in your ViewController

Returning YES is guaranteed to allow simultaneous recognition and returning NO is not guaranteed to prevent simultaneous recognition, as the other gesture's delegate may return YES

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{

  return YES;

}
查看更多
登录 后发表回答