我正在使用这种方法,但它仅适用于我的 UIView 子类。如果我点击 UITextView 或 UIButton 或任何其他对象,它不会显示坐标。如何获取 UITextView 上的点击坐标?为什么会这样?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *userTouch = [[event allTouches] anyObject];
CGPoint currentPos = [userTouch locationInView:self.view];
NSLog(@"Coordinates: (%f,%f)", currentPos.x, currentPos.y);
}