views:

1187

answers:

1

OK i am really struggling with this!

I know had to add an image to the view, i know how to record a touch event. But combining the two is proving to be an issue.

There are lots of tutorials out there on how to move an image with touch events.

But Could anyone suggest how i might complete the following:

  • Add an image to the view on touch
  • Add the same image on another touch received by the user.
  • Manipulate the location of the added images when the user touches a previously added image

Any advice would be highly appreciated

+1  A: 

Supposing that you want to simply let the image appear and disappear, you could just implement the UITouch event handling methods in the UIViewController for the view that you want to intercept the touch events in. An example on how to do this can be found in the "iPhone Programming Guide: Event Handling" at:

http://developer.apple.com/IPhone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/EventHandling/EventHandling.html#//apple%5Fref/doc/uid/TP40007072-CH9

Once you have managed to intercept the touch events, you can simply add the UIImageView as a subview of the view you want it to appear in.

I hope that helped a bit.

LeonBrussels
Thank you very helpful... i can successfully add an image on touch now. I just need to figure out how to include the extra implementation as explained in my comment above :)
Tom G