2010-08-21 17 views
2

在蘋果的文檔,事件處理指南適用於iOS,部分 「Best Practices for Handling Multitouch Events」:爲什麼Apple的文檔說你不要在UIView的子類中調用超類的事件處理方法?

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. 

爲什麼?我不明白這兩種情況的第二點背後的理由。這不取決於不同的情況嗎?

回答

1

它可能涉及到後來的一點:

不要了應答(通過nextResponder)明確發送事件;相反,調用超類實現並讓UIKit處理響應者鏈遍歷。

如果你處理touchesBegan:withEvent:和touchesEnded:withEvent :, UIView用touchesMoved做什麼:withEvent:?它應該轉發給響應者鏈嗎?

+0

我添加了另一個案例(任何其他UIKit響應者類的子類)。你的解釋是否也適用於附加案例? – yehnan 2010-08-21 05:48:04

相關問題