以自定义方式从 UIApplication 传播触摸
是否可以将触摸从共享应用程序对象传播到尚未实际接收触摸且位于顶视图后面某处的自定义视图? 假设我无法使用顶视图来跟踪触摸。
Is it possible to propagate touches from shared application object to a custom view which has not actually received touches and somewhere at the back of the top view? Assume that I can't use my top view to track touches.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这会很困难 - 因为顶视图首先接收事件。
你不能只在顶层视图上调用 userInterActionEnabled ,然后将事件传递到较低层吗?
It would be difficult - because the top view receives the event first.
You can't just call userInterActionEnabled on the top view, and pass the event down to a lower layer?
为什么不能使用顶视图来跟踪触摸?
如果顶视图是子类,那么您可以使用 TouchBegan: 方法。 要将其传递到另一个子类,您可以使用 NSNotificationCenter,将触摸集作为对象传递。 如果您对此不熟悉,可以查看我在这篇文章中的解释:
Hittest 事件问题
Why can you not use the top view to track touches?
If the top view is a subclass then you can use the touchesBegan: method. To pass this onto another subclass you could just use NSNotificationCenter, passing the set of touches as the object. If you're unfamiliar with this you can check out my explanation on this post:
Hittest event problem