touches
//当有一个或多个手指触摸事件在当前视图或window窗体中响应
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject]; //视图中的所有对象
CGPoint point = [touch locationInView:self.view]; //返回触摸点在视图中的当前坐标
int x = point.x;
int y = point.y;
NSLog(@"touch (x, y) is (%d, %d)", x, y);
}
UITapGestureRecognizer 获取点击位置
-(void)handleSingleTap:(UITapGestureRecognizer *)sender
{
CGPoint touchPoint = [sender locationInView:self.view];
}
网友评论