Move Multiple Object With Touch In iPhone

In this application we will see how to handle touches, including multiple touches that move multiple objects. After the application launches, three colored pieces appear onscreen that the user can move independently. Touches cause up to three lines of text to be displayed at the top of the screen.

Step 1: Create a Window base application using template. Give the application name “TouchImage”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Now we’ll add UIView class to the project. Choose New file -> Select cocoa touch classes group and then select UIView. Give the name ViewImage.

Step 4: In the ViewImage.h file we have added UIImageView,UILabel. Make the following changes in the file.

 

 

 

Step 5: Now double click your MainWindow.xib file open it in the Interface Builder.  Drag the view from the library and place it to the window. Select view and bring up Identity Inspector change the class name into ViewImage. Now Drag Image view and label  from the library and place it to the view window.

Step 6: Now the make the following changes in the ViewImage.m file.

 

 

 

Step 7: Compile and run the application on the simulator.

You can downloaded SourceCode from here TouchImages

Leave a Comment:

1 comment
DANIEL says January 6, 2011

I got:

Undefined symbols:
“_CGRectCountainsPoint”, referenced from:
-[ViewImage dispatchTouchEvent:toPosition:] in ViewImage.o
-[ViewImage dispatchTouchEvent:toPosition:] in ViewImage.o
-[ViewImage dispatchTouchEvent:toPosition:] in ViewImage.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

is this becouse there is no connecting by InterfaceBuilder? Also I got a lot Warnings about @synthesise… I impemented yet.

Thanks for responding 🙂

Reply
Add Your Reply