Finding coordinates of gesture touch using locationOfTouch

你。 提交于 2019-12-10 10:25:00

问题


Hey, been trying to get the location of a users swipe so that I can have 3 swipe-able areas on screen and determine which section they react with based on the y coordinates of their swipe.

This is the code

CGPoint touchPoint = [recognizer locationOfTouch:0 inView:nil];

I have tried printing the touchPoint.y in a label and all i get is 0. How do I get the coordinates of the users swipe?

Thanks.


回答1:


Its strange but setting view as nil or self.view.window is returning 0. There is no mention of such behavior and Apple doc on UISwipeGestureRecognizer seems to encourage finding the origin of the swipe using this method. It would be a good idea to file this under a bug.

This is working for other views though. Say self.view.



来源:https://stackoverflow.com/questions/6060438/finding-coordinates-of-gesture-touch-using-locationoftouch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!