开发者

Get touch points in UIScrollView through UITapGestureRecognizer

开发者 https://www.devze.com 2023-03-24 22:50 出处:网络
i am using UIScrollview and UITapGestureRecognizer for getting touch event. Now, i want x and y coordinates for my touch position.

i am using UIScrollview and UITapGestureRecognizer for getting touch event.

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

any help P开发者_如何学JAVAlease?


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'...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消