Can we add single gesture on multiple views and make it working? [duplicate]

守給你的承諾、 提交于 2019-12-06 13:06:30
Sebastian

I don't think it's possible.

Please have a look at https://stackoverflow.com/a/5567684/470964.

Also https://stackoverflow.com/a/7883902/470964: Maybe it's also a solution for your problem. I think the answer is that the GestureRecognizer has only one view property, that will be set.

From the docs for UIGestureRecognizer

A gesture recognizer operates on touches hit-tested to a specific view and all of that view’s subviews. It thus must be associated with that view. To make that association you must call the UIView method addGestureRecognizer:. A gesture recognizer does not participate in the view’s responder chain.

So, in summary the only way a GestureRecognizer can operate on more than one view is if the recognizer operates on a superview of the other views.

Can't you just write your invokePanGesture method to do the same thing to both views at the same time?

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