问题
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