首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么苹果的文档说你不在UIView的子类中调用超类的事件处理方法?

为什么苹果的文档说你不在UIView的子类中调用超类的事件处理方法?
EN

Stack Overflow用户
提问于 2010-08-21 11:10:32
回答 1查看 112关注 0票数 2

在苹果公司的文档iOS事件处理指南中,“Best Practices for Handling Multitouch Events”一节:

代码语言:javascript
复制
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.

代码语言:javascript
复制
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. 

为什么?我不明白这两种情况的第二点背后的理由。这不是取决于不同的情况吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-08-21 12:11:22

这可能与后面的一点有关:

不显式地(通过nextResponder)将事件向上发送到响应器;相反,调用超类实现并让UIKit处理响应器链遍历。

如果您处理触摸handle :withEvent:和touchesEnded:withEvent:,那么UIView如何处理touchesMoved:withEvent:?它应该将其转发到响应器链上吗?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3536114

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档