I have programatically added a UIImageView. How do I make it send a message to my controller when the users clicks it, sending itself as the only parameter?
views:
1329answers:
3
+3
A:
- Create a new class that extends UIImageView and use that.
- In your class, override the touch events - touchesBegan, touchesEnded and/or touchesMoved as appropriate
- From those methods, call back to a method on the controller.
Eric Petroelje
2009-03-11 20:23:44
You also have to set the userInteractionEnabled property to YES.
Chris Lundie
2009-03-11 21:52:58
+3
A:
I'd just put a custom button over the UIImage view, and use normally - buttons with Custom style are invisible and so will not obscure the image. It's also a great way to turn regions of text into clickable areas as well.
Or, you could assign the custom image as a graphic background for the button.
Kendall Helmstetter Gelner
2009-03-11 23:00:42
+5
A:
I wouldn't use a UIImageView unless there was some other compelling reason. I'd just use a custom UIButton and use the UIImage as its background.
Tom Harrington
2009-03-11 23:27:44