在苹果公司的文档iOS事件处理指南中,“Best Practices for Handling Multitouch Events”一节:
If you handle events in a subclass of UIView, UIViewController, or (in rare cases) UIResponder,
You should implement all of the event-handling methods (even if it is a null implementation).
Do not call the superclass implementation of the methods.和
If you handle events in a subclass of any other UIKit responder class,
You do not have to implement all of the event-handling methods.
But in the methods you do implement, be sure to call the superclass implementation. 为什么?我不明白这两种情况的第二点背后的理由。这不是取决于不同的情况吗?
发布于 2010-08-21 12:11:22
这可能与后面的一点有关:
不显式地(通过nextResponder)将事件向上发送到响应器;相反,调用超类实现并让UIKit处理响应器链遍历。
如果您处理触摸handle :withEvent:和touchesEnded:withEvent:,那么UIView如何处理touchesMoved:withEvent:?它应该将其转发到响应器链上吗?
https://stackoverflow.com/questions/3536114
复制相似问题