菜鸟教程小白 发表于 2022-12-13 09:37:36

objective-c - UIResponder 类和第一响应者角色


                                            <p><p>我在 <code>UIResponder</code> 类引用中读到:</p>
<blockquote>
<p>There are two general kinds of events: touch events and motion events.</p>
<p>The primary event-handling methods for touches are touchesBegan:withEvent:, touchesMoved:withEvent:, touchesEnded:withEvent:, and touchesCancelled:withEvent: ...</p>
</blockquote>
<p>但另一篇文章,iOS 事件处理指南说:</p>
<blockquote>
<p>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</p>
</blockquote>
<p>所以我很困惑,第二个注释说响应者只处理四个事件——不包括触摸事件——而第一个注释说响应者处理触摸事件。</p>
<p>请让我知道我的误解。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>一次只有一个响应者是第一响应者。此响应者首先查看您引用的四种事件类型。触摸事件总是首先进入被触摸的 View 。在您引用的段落之后的几段中对此进行了解释:</p>

<blockquote>
<p>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
<code>hitTest:withEvent:</code>; for “shaking”-motion events, remote-control
events, action messages, and editing-menu messages, that view is the
first responder.</p>
</blockquote></p>
                                   
                                                <p style="font-size: 20px;">关于objective-c - UIResponder 类和第一响应者角色,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/7961754/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/7961754/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: objective-c - UIResponder 类和第一响应者角色