Re: How to assign a method for touch event to a UIImageView?
Re: How to assign a method for touch event to a UIImageView?
- Subject: Re: How to assign a method for touch event to a UIImageView?
- From: Dave DeLong <email@hidden>
- Date: Fri, 24 Jun 2011 13:40:18 -0700
On Jun 24, 2011, at 1:36 PM, Fritz Anderson wrote:
> UIImageView is not a control, so it doesn't have built-in handlers for touches that would feed a target-action pair. You'll have to make a subclass of UIImageView (in my experience it tolerates subclassing well), and add your own touchesBegan/Moved/Cancelled/Ended methods.
Yeesh, talk about a sledgehammer approach.
You can simply attach a UITapGestureRecognizer to the view, turn on user interaction, and you're done.
Or you can use a UIButton without a bezel and show your image in the bezel, and then just wire up the button like you would any other button. Tap detection is built into the system. It's not worth rebuilding that when it's baked into the frameworks.
Dave
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden