在我的代码中,我需要找到用户触摸和当前平移的坐标。我基于UIPanGestureRecognizer
中的触摸坐标设置了以下代码内容如下:
CGPoint pos = [gestureRecognizer locationInView:[gestureRecognizer view]];
然而,这个方法返回的值要么是负值,要么大于视图本身的框架。这怎么可能呢?我做错了什么?
谢谢
试试这个它给了我x和y的坐标
-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
CGPoint touchPoint = [gestureUp locationOfTouch:0 inView:gestureUp.view];
if (touchPoint.y <= 160)
{
if (gestureUp.direction == UISwipeGestureRecognizerDirectionUp)
{
NSLog(@"the location x...%f",touchPoint.x);
NSLog(@"the location y...%f",touchPoint.y);
}
else
{ }
}
return YES;
}