• 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: Fritz Anderson <email@hidden>
  • Date: Fri, 24 Jun 2011 15:36:17 -0500

On 24 Jun 2011, at 3:26 PM, Jonathan Chacón Barbero wrote:

> I want to execute a method when the user touches a UIImageView.
> I designed my interface without Interface builder tools because I am blind.
>
> I can add an action to a UIButton with this code:
>
> [myButton addTarget:self action:@selector(onFotoClick:) forControlEvents:UIControlEventTouchUpInside];
>
> but this code doesn't work with an UIImageView.
>
> How can I do this with this class?

I admire your perseverance in programming for iOS though blind. I'm not sure I'd do as well.

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.

	— F

_______________________________________________

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

  • Follow-Ups:
    • Re: How to assign a method for touch event to a UIImageView?
      • From: Alex Kac <email@hidden>
    • Re: How to assign a method for touch event to a UIImageView?
      • From: Dave DeLong <email@hidden>
References: 
 >How to assign a method for touch event to a UIImageView? (From: Jonathan Chacón Barbero <email@hidden>)

  • Prev by Date: How to assign a method for touch event to a UIImageView?
  • Next by Date: Re: How to assign a method for touch event to a UIImageView?
  • Previous by thread: How to assign a method for touch event to a UIImageView?
  • Next by thread: Re: How to assign a method for touch event to a UIImageView?
  • Index(es):
    • Date
    • Thread