Monday, April 11, 2011

Tutorial on UIGestureRecognizer

I am going to cover Gestures topic today.

We have 2 views on our ViewController , they toggle on the swipe gesture of the user.

You will need to define a view class with the gesture added to it as following

You will have to define a protocol in its header file to be able to talk to main controller class which we will implement below in the blog.

This is another view with another swipe gesture implemented on it.
Same as above class we will to create protocol in its header file as well to be able to talk to main view controller.

Now we have a view controller class, where above views are added as sub view.

Firstly , there is view 1 visible and view 2 is hidden.
User swipes to left, it will hide view 1 and  display view 2.
User swipes to right, it will hide view 2 again and display view 1.

You can the protocol methods implemented in this view controller class.

You will have to include the class1 and class2 protocol in your view controller's header file as following:

You can download the code, to study the code more deeply.

Download Sample Code

No comments:

Post a Comment