OGeek|极客世界-中国程序员成长平台

标题: objective-c - UIResponder 类和第一响应者角色 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 09:37
标题: objective-c - UIResponder 类和第一响应者角色

我在 UIResponder 类引用中读到:

There are two general kinds of events: touch events and motion events.

The primary event-handling methods for touches are touchesBegan:withEvent:, touchesMoved:withEvent:, touchesEnded:withEvent:, and touchesCancelled:withEvent: ...

但另一篇文章,iOS 事件处理指南说:

The first responder is the first view in a window to receive the following type of events and messages: Motion events, Remote-control events, Action messages, Editing-menu messages

所以我很困惑,第二个注释说响应者只处理四个事件——不包括触摸事件——而第一个注释说响应者处理触摸事件。

请让我知道我的误解。



Best Answer-推荐答案


一次只有一个响应者是第一响应者。此响应者首先查看您引用的四种事件类型。触摸事件总是首先进入被触摸的 View 。在您引用的段落之后的几段中对此进行了解释:

When the system delivers a touch event, it first sends it to a specific view. For touch events, that view is the one returned by hitTest:withEvent:; for “shaking”-motion events, remote-control events, action messages, and editing-menu messages, that view is the first responder.

关于objective-c - UIResponder 类和第一响应者角色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7961754/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4