iPad - 同时识别同一手势
我需要一个用户可以绘制多个矩形的视图。现在我需要能够使用平移手势移动这些矩形。我遇到的问题是我可以使用平移手势识别器移动任何单个矩形,没有任何问题。现在,当我用 2 个手指平移 2 个矩形以同时移动时,它不起作用。
在我看来,问题是我为平移手势指定的目标/操作仅被触发一次。
我的观点采用 UIGestureRecognizerDelegate 并定义了这个委托方法:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
提前致谢!
I need have a view where users can draw multiple rectangles. Now I need to be able to move those rectangles using a Pan gesture. The problem I am having is that I can move any single rectangle with the Pan gesture recognizer with no problem. Now when I use 2 fingers to Pan 2 rectangles to move simultaneously it doesn't work.
Seem to me that the problem is the target/action that I specified for the pan gesture gets fired only once.
My view adopts the UIGestureRecognizerDelegate and has defined this delegate method:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过创建一个方法,将手势识别器分别添加到每个创建的矩形视图中。
像这样
您可以循环将手势识别器同时添加到所有片段,或者在创建每个矩形时,只需在创建矩形后触发此方法,并将其作为片段参数传递给此函数。
那应该有帮助。
Add gesture recognizer to each created rectangle view individually by making a method.
like this
You can loop in to add the gesture recognizer to all the pieces simultaneously, or while u create each rectangle, just fire this method after creating the rectangle, and passing that as the piece parameter to this function.
That should help.