How can I detect the touch event of an UIImageView?

ebaccount picture ebaccount · May 13, 2009 · Viewed 128.7k times · Source

I have placed an image (UIImageView) on the navigation bar. Now I want to detect the touch event and want to handle the event. How can I do that?

Answer

Kendall Helmstetter Gelner picture Kendall Helmstetter Gelner · May 13, 2009

In practical terms, don't do that.

Instead add a button with Custom style (no button graphics unless you specify images) over the UIImageView. Then attach whatever methods you want called to that.

You can use that technique for many cases where you really want some area of the screen to act as a button instead of messing with the Touch stuff.