开发者

Why does Apple's doc say that you don't call the superclass's event handling methods in subclass of UIView?

In Apple's document, Event Handling Guide for iOS, the section "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.

and

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, b开发者_C百科e sure to call the superclass implementation. 

Why? I don't understand the rationale behind point 2 of both cases. Doesn't it depend on the different situations?


It probably relates to the later point:

Do not explicitly send events up the responder (via nextResponder); instead, invoke the superclass implementation and let the UIKit handle responder-chain traversal.

If you handle touchesBegan:withEvent: and touchesEnded:withEvent:, what does UIView do with touchesMoved:withEvent:? Is it supposed to forward it up the responder chain?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜