Get touch points in UIScrollView through UITapGest

2019-07-13 15:16发布

i am using UIScrollview and UITapGestureRecognizer for getting touch event.

Now, i want x and y coordinates for my touch position.

any help Please?

1条回答
孤傲高冷的网名
2楼-- · 2019-07-13 15:48

In your gesture recognizer handler:

 CGPoint location = [gestureRecognizer locationInView:gestureRecognizer.view];

you could specify a different view, if you need it.

or u can use this also It belongs in a View rather than ViewController, and would look something like this:

-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)evt {
  UITouch *touch=[touches anyObject];
  CGPoint pt=[touch locationInView:self];
  // ...make your button at 'pt'...
}
查看更多
登录 后发表回答