• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to assign a method for touch event to a UIImageView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Matt Neuburg <email@hidden>
  • Date: Wed, 29 Jun 2011 08:42:25 -0700

On Fri, 24 Jun 2011 22:26:42 +0200, Jonathan Chac?n Barbero <email@hidden> said:
>
>I want to execute a method when the user touches a UIImageView.

In my book, I actually give a solution to this (in the Touch Delivery section of the Touches chapter): set the UIImageView's userInteractionEnabled to YES and attach a UITapGestureRecognizer to it or to its superview. If you attach the UITapGestureRecognizer to the superview, you can use hit-testing to determine whether the UIImageView was tapped:

CGPoint p = [g locationOfTouch:0 inView:self]; // g is the gesture recognizer
UIView* v = [self hitTest:p withEvent:nil];

m.

--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________

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

  • Prev by Date: Re: who is currently the first responder? (iOS)
  • Next by Date: Re: Properties, Attributes and Retain+Autorelease
  • Previous by thread: Re: How to assign a method for touch event to a UIImageView?
  • Next by thread: Problem with NSOperation exiting and crashing the app
  • Index(es):
    • Date
    • Thread