Skip to content

Instantly share code, notes, and snippets.

@ishida
Created November 22, 2012 05:38
Show Gist options
  • Save ishida/4129569 to your computer and use it in GitHub Desktop.
Save ishida/4129569 to your computer and use it in GitHub Desktop.
Detect touches
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint p = [touch locationInView:aView];
NSLog(@"Touch detected: x=%lf, y=%lf", p.x, p.y);
if (0 <= p.y && p.y <= aView.frame.size.height
&& 0 <= p.x && p.x <= aView.frame.size.width)
{
//do something
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment