Created
January 10, 2012 13:16
-
-
Save pita5/1589040 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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