Skip to content

Instantly share code, notes, and snippets.

@pita5
Created January 10, 2012 13:16
Show Gist options
  • Save pita5/1589040 to your computer and use it in GitHub Desktop.
Save pita5/1589040 to your computer and use it in GitHub Desktop.
@interface MWViewController ()
{
UIScrollView *scrollView;
UIView *toHit;
}
@end
@implementation MWViewController
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)tap:(UITapGestureRecognizer *)tap
{
CGPoint point = [tap locationInView:scrollView];
id something = [scrollView hitTest:point withEvent:nil];
if (something == toHit)
{
NSLog(@"success");
}
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
[self.view addSubview:scrollView];
toHit = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
[scrollView addSubview:toHit];
toHit.backgroundColor = [UIColor redColor];
[scrollView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)]];
// Do any additional setup after loading the view, typically from a nib.
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment