Reading through the documentation here.
I know how to successfully setup PAN gestures for a C4Object. How would I disable a PAN gesture though?
Using...
[object setUserInteractionEnabled:NO]
... disables all gestures including TAP events and...
object.gestureRecognizers = NO
... doesn't allow me to reinitialize PAN gestures.
If anyone could share with me how disable PAN gestures (toggle PAN on/off) without effecting other gesture events it would be greatly appreciated.
You can get access to the gestures that you add to an object by using the
gestureForName:method, which returns aUIGestureRecognizerobject. From there, you can interact with that gesture recognizer and change its properties directly.To toggle on/off a gesture recognizer, all you have to do is change the value of its
enabledproperty.The following works for me:
The key part of this example is the following:
Notice, in the implementation there is a
UIGestureRecognizervariable calledgesture. What we do on the second line is find thePANgesture associated with thesquareobject and keep a reference to it.Then, whenever we toggle by touching the circle we do the following:
That is, if the gesture is enabled then disable it (and vice-versa).
You can check out more on the UIGestureRecognizer Class Reference