Learning iPad Programming: Using Gesture Recognizers (Podcast Transcript)
Hi. I'm Kirby Turner, and I'm the author of Learning iPad Programming: A Hands-on Guide to Building iPad Apps with iOS 5. In this episode, I'm gonna talk about using gesture recognizers.
With the release of UIGestureRecognizer, all that code now can be isolated into a single class. You create an instance of the class, you add it to your view, and now your view is able to detect that gesture. You can write your own custom gesture, but Apple has also provided a number of predefined touch gestures that you can take advantage of in your app. There's a tap gesture, a pinch gesture, a rotation gesture, a swipe gesture, and even a pan gestureso if you want to grab, say, a photo and move it around your screen, you can.
For example, let's say that you wanted to detect a double-tap within your view. What you would do is create a UITapGestureRecognizer. Prior to adding it to the view, you would set the number of required taps to two, because you are wanting to detect the double-tap (which is two taps), and then you add it to your view, and you're done.
Now, when you run your application, if the user double-taps that view, the recognizer will detect that gesture and report back to your application.
That's my tip for the day, and I hope you enjoyed it.
Kirby Turner discusses the differences between using the UIImagePickerController and the AssetsLibrary framework to work with photos and video, in the article "Learning iPad Programming: Accessing the Photo Library."
For more information, visit onpodcastweekly.com and subscribe to all our podcasts. Brought to you by the publishing imprints and information portal of Pearson Education.