Is "self.view" the same thing as "button"? You're using the former to produce a CGPoint, but the latter to produce a bounding rectangle. My guess is that they're not the same, which means the point is in a different coordinate system than "button.bounds".
HTH, Dave On Apr 18, 2010, at 9:02 AM, Joshua Garnham wrote: > I am trying to make an if statement which will check whether the users touch > is within a > UIButton's bounds. I thought this would be an easy affair as UIButton > is a subclass of UIView, however my code doesn't seem to work. > This is the code I have been using. > - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { > NSArray *array = [touches allObjects]; > UITouch *specificTouch = [array objectAtIndex:0]; > currentTouch = [specificTouch locationInView:self.view]; > if (CGRectContainsPoint(button.bounds, currentTouch)) { > //Do something. > } > //Else do nothing. > }
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com