Re: Contain touches within UIImageView only
Re: Contain touches within UIImageView only
- Subject: Re: Contain touches within UIImageView only
- From: glenn andreas <email@hidden>
- Date: Wed, 02 Dec 2009 13:59:59 -0600
On Dec 2, 2009, at 12:23 PM, Chunk 1978 wrote:
> i have a custom class for a UIImageView which contains touch methods.
> at launch, the custom UIImageView is added (by interface builder) as a
> subview to the main UIViewController's view.
>
> i can't seem to make the touch methods only trigger if they are within
> the custom UIImageView. for some reason, touchesBegan works fine, but
> touchesMoved will continue to fire even if the CGPoint is no longer on
> the custom UIImageView
"For some reason" = "Because that's how it is suppose to work"
Consider the case of a button that remove highlighting if you tap on it and then drag off the button - if it didn't get the moved message when it was moved off the content, it would never know to remove the highlighting (and UIControl even implements a bunch of events for things like TouchDragEnter, TouchDragExit, TouchDragOutside, TouchUpOutside, etc...)
Once you get a touchesBegan for a UITouch, you should continue to get touchesMoved until your get a touchesEnded or touchesCanceled
How you treat the events (be they inside your content or not - and many control actually consider their content area to be much larger while tracking for better user experience), is entirely up to you. You can always test their location and ignore them...
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
Mad, Bad, and Dangerous to Know
_______________________________________________
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