How To Implement Touch Function In iPhone?

We are going to build a little application that will give you a better feel for when  the four touch responder methods get called.

Step 1: In Xcode , create a new project using the view-based application template .

Step 2: Now, double click the .xib file to open the file in Interface Builder. If the window title View is not open , double click the view icon to open it. Drag label from the library to the View window. And delete it rename touchesLabel outlet. Control drag from the File’s Owner icon to the touchesLabel outlet. Finally , bring up the attributes inspector. On the inspector, make sure that both User Interface Enabled and Multiple Touch are checked. If Multiple Touch is not checked, your controller class’s touch methods will always receive one and one touch .

Step 3: In this controller class, we implement all four of the touch-related methods. Just see below:

 

 

 

Step 4: Now compile and run the application , If you’re running in the simulator you’ll see the output.

Figure 1: Touch Explorer Application.

Leave a Comment: