Evan Anger
Evan Anger

Reputation: 714

Programmatically starting a UIGestureRecognizer

I have a UIGestureRecognizer which occurs on tap down. It causes a new UIViewController subview to be added over it. The touch is still down. I would like to start a UIPanGesture automatically on this new view. The user can just continue moving their finger on this subview and drag certain UI elements around at this point.

Any ideas from others on an approach to this problem?

Upvotes: 1

Views: 205

Answers (1)

Evan Anger
Evan Anger

Reputation: 714

So I'm approaching the problem incorrectly. I had very limited success in programmatically beginning a gestures. What I did instead was added a subclassed UIPanGesture to a higher level view. Using UIGestureRecognizerDelegate I could control its behavior on initial tap down and subsequent panning.

In general, I believe the way apple would prefer you handle the above feature would to just allow your gestures to work but use the delegate methods to control which one takes precedence first by using the following method - gestureRecognizer:shouldRequireFailureOfGestureRecognizer: – gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer:

Upvotes: 1

Related Questions