So I believe there are numerous options for handling touch events when programming for the iDevices. A few of the options that I have come a cross are UITapGestureRecognizer and of course using UIButtons. Are there anymore options? What options are most suitable to use? Perhaps someone has a link to a guide or a tutorial that sums this up?
Cheers,
Peter
1) Target-action:
UIControl(UIButtonis a subclass of that) provides some built-in touch handling by adding a target and action for certain types of touch events. Example:2) Overriding the
UIViewmethodstouchesBegan:withEvent:,touchesMoved:withEvent:,touchesEnded:withEvent:andtouchesCancelled:withEvent:– Provides very fine-grained control but can be difficult to use for complex multitouch handling.3) Gesture recognizers (since iOS 3.2): Recognition of multitouch (or single touch) gestures that are usually comprised of multiple touch events. The built-in gesture recognizers provide support for recognizing taps, pinches, rotation gestures, swipes, panning and long presses. It’s also possible to create custom gesture recognizers for more complex gestures.
All the gesture recognizer subclasses are customizable to a certain degree, e.g. you can specify a minimum number of taps and touches for a
UITapGestureRecognizer.Generally, gesture recognizers can both provide discrete events (like a tap) and continuous events (like a rotation that changes its angle over time).