从 UILongPressGestureRecognizer 获取屏幕坐标
问题描述:
我正在尝试在 iOS 应用中实现 UILongPressGestureRecognizer.它按预期触发,但我没有看到将屏幕坐标传递给我的目标方法.有人知道怎么做吗?
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 anyone know how to do this?
答
这似乎是一个动作:
- (void)receivedLongPress:(UIGestureRecognizer *)gestureRecognizer
{
CGPoint coords = [gestureRecognizer locationInView:gestureRecognizer.view];
}
我仍然不太明白(似乎最后一个接触点存储在gestureRecognizer中,在这种情况下,我希望只有一个属性或其他东西).但是,嘿,它有效.
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.