Getting screen coordinates from UILongPressGestureRecognizer

后端 未结 1 1103
无人及你
无人及你 2021-01-05 17:38

I am trying to implement a UILongPressGestureRecognizer in an iOS app. It fires as expected, but I don\'t see anyway of passing screen coordinates to my target method. Does

相关标签:
1条回答
  • 2021-01-05 18:15

    This seems to work as an action:

    - (void)receivedLongPress:(UIGestureRecognizer *)gestureRecognizer 
    {
         CGPoint coords = [gestureRecognizer locationInView:gestureRecognizer.view];
    }
    

    I still don't really understand (it seems like the last touch point is stored in the gestureRecognizer, in which case I would expect there to just be a property or something). But hey, it works.

    0 讨论(0)
提交回复
热议问题