• 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
Checking if a touch is within a UIButton’s bounds.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking if a touch is within a UIButton’s bounds.


  • Subject: Checking if a touch is within a UIButton’s bounds.
  • From: Joshua Garnham <email@hidden>
  • Date: Sun, 18 Apr 2010 15:02:10 +0000 (GMT)

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.
}




_______________________________________________

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: Checking if a touch is within a UIButton’s bounds.
      • From: Dave DeLong <email@hidden>
  • Prev by Date: Re: +Hi+
  • Next by Date: Re: Checking if a touch is within a UIButton’s bounds.
  • Previous by thread: Re: [Moderator] Re: +Hi+
  • Next by thread: Re: Checking if a touch is within a UIButton’s bounds.
  • Index(es):
    • Date
    • Thread