Just started iOS programming, trying to get UITapGestureRecognizer working using iOS 5.1 simulator, and i can't seem to get the right values when tapping. here's my code that i took from nathan eror's answer to nathan eror's How to add a touch event to a UIView?
- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer {
CGPoint location = [recognizer locationInView:[recognizer.view superview]];
NSLog(@"touched points: %g, %g", location.x, location.y);
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor blackColor];
NSLog(@"gets in here");
UITapGestureRecognizer *singleFingerTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSingleTap:)];
[self.view addGestureRecognizer:singleFingerTap];
}
and i keep getting 0.000000 for my values every time i tap on the trackpad on my macbook pro on the simulator. is it because of the simulator? or am i doig something morbidly wrong?
P.S does anyone know how to highlight the code as objective-C in posting this question? thnx in advance