仅在父视图上捕获 UIGestureRecognizer
我有两个视图控制器,可以容纳与子视图相同的组件。
该组件实现了 UIDragGestureRecognizer 的处理。
控制器 A 还处理拖动手势,并且应该覆盖组件的默认拖动行为。
所以问题是,如果该组件是控制器 B 的子视图,那么我希望该组件捕获拖动事件,但如果它是控制器 A 的子视图,那么我不希望它捕获拖动事件。
将 UIDragGestureRecognizer 添加到controllerA.view 会导致控制器和组件接收拖动事件,这对我来说很糟糕。
如果组件是控制器 A 的子视图,如何确保该组件不会接收拖动事件? (我在初始化时将 UIGestureRecognizer 添加到组件中,当时我仍然不知道哪个控制器将保存它)。
I Have two view controllers that can hold the same component as a subView.
The component implements handling UIDragGestureRecognizer.
Controller A also handles drag gestures and should override the default drag behavior of the component.
So the problem is that if the component is a subView of controller B than i want the component to catch drag events, but if it's a subView of controller A than i don't want it to catch drag events.
Adding a UIDragGestureRecognizer to controllerA.view causes both the controller and the component to receive the drag event which is bad for me.
How can I make sure that the component will not receive drag events if it's a subView of controller A? (I'm adding the UIGestureRecognizer to the component at initialization and at that time i still don't know which controller will hold it).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[组件removeGestureRecognizer:component.myGestureRecognizer];
[component removeGestureRecognizer:component.myGestureRecognizer];