How To Detect Multiple Taps In iPhone?

Detecting multiple taps is very easy to use. If the user triple taps, you get notified three separate times. You get a single-tap, a double tap and finally triple tap. lets see how it is worked.

Step 1: In Xcode, create a new project with view base application template.

Step 2: Next, double click .xib file to open the file in Interface Builder. Once you’re there ,make sure you set the view to accept multiple touches, and then add four Labels to the view from the library. Once you are done, double click each lebel and press the delete key to get rid to any text. Now control drag from the File’s Owner icon to each label , and connect each one to singleLabel, doubleLabel, tripleLabel, and quadrupleLabel, respectively. Now you can save and go back to  Xcode.

Step 3: The four methods do nothing more in this application than set one of the four labels and use performSelector:withObject:afterDelay: to erase that same label after 1.6 seconds. The eraseMe: method erases any text field that is passed into it.




Step 4: Compile and run this application , and when you double, triple, quadruple tap, you should only see one label displayed. See the figure below:

Figure 1: Detecting Tap Application.

You can downloaded SourceCode from here TapTaps 2

Leave a Comment:

1 comment
Dilmer says July 12, 2012

THANK YOU! WOrks great

Add Your Reply