Saturday, April 9, 2011

Recognize single and double tap on iPhone using UITapGestureRecognizer

If you have used elements like UIButton, UIImageView and you want to find out whether user tapped once or twice on it then you can do following and solve the problem very easily !

1. Create a subclass of UIButton or UIImageView whatever it is, in its implementation class you can define UITapGestureRecognizer methods like following:

Then one of the following methods will be executed whenever a touch event is generated by user.You need to write these methods in the same file as above .

And your work is finished here now. You can just create an object of the class you have defined above and enjoy the single tap / double tap work like charm ... you dont need to code the hell out to recognise the single or double tap now !!

1 comment:

  1. Thanks for sharing information.
    online recharge
    Existing customers can avail the tariff benefit of ALL LOCAL CALLS at 25P/min for 3 months on Special Tariff voucher (STV)priced at Rs 38 only in Haryana.