嗨,我想获取任何控件的触摸位置/点或发生触摸的任何位置。
为此,我已经实现了这一点,但我没有得到正确的接触点。
// Create gesture recognizer, notice the selector method
UITapGestureRecognizer *oneFingerTwoTaps =
[[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(oneFingerTwoTaps)] autorelease];
oneFingerTwoTaps.delegate=self;
// Set required taps and number of touches
[oneFingerTwoTaps setNumberOfTapsRequired:1];
[oneFingerTwoTaps setNumberOfTouchesRequired:1];
[[self view] addGestureRecognizer:oneFingerTwoTaps];
和
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
CGPoint point= [touch locationInView:touch.view];
NSLog(@"Point - %f, %f",point.x,point.y);
NSLog(@"Touch");
return NO; // handle the touch
}
当我试图点击任何 UIButton、UIImage、UITableView 时,它没有给我正确的点击点,我做错了什么吗?请帮我。谢谢你。