iOS 事件传递及响应过程

—->>事件到来——>>事件分发 ——>>事件响应


事件( Events)

官方文档( Events(iOS)) 是这样描写叙述的:

Users manipulate their iOS devices in a number of ways, such as touching the screen or shaking the device. iOS interprets when and how a user is manipulating the hardware and passes this information to your app. The more your app responds to actions in natural and intuitive ways, the more compelling the experience is for the user.

1.触摸事件( Touch Events) (单点事件、多点触摸及各种手势)

2.晃动时间(Motion Events) (重力、加速度等传感器)

3.远程控制事件(Remote-Control Events)(线控耳机、AirPlay 等)


事件分发( Event Delivery)

触摸事件:触摸->硬件中断-> UIKit 封装成 UIEvent对象->当前执行的应用程序的事件队列 - >UIApplication 对象 - >key window - >Hit - Testing VIew

其它事件:key window - > First Responder

目的:

The ultimate goal of these event paths is to find an object that can handle and respond to an event. Therefore, UIKit first sends the event to the object that is best suited to handle the event. For touch events, that object is the hit-test view, and for other events, that object is the first responder.

方法:

- Hit-Testing Returns the View Where a touch Occurred (Touch)

The hit-test view is given the first opportunity to handle a touch event. If the hit-test view cannot handle an event, the event travels up that view’s chain of responders as described in “ The Responder Chain Is Made Up of Responder Objects ” until the system finds an object that can handle it.

- The Responder Chain Is Made Up of Responder Objects (Motion Or R-C)


事件响应



注意:

hitTest:withEvent: 方法将会忽略( hidden = YES) 的视图

禁止用户操作( userInteractionEnabled = NO) 的视图

以及 alpha 级别 小于0.01 (alpha < 0.01) 的视图

假设一个子视图的区域超过父视图的 bound 区域(父视图的 clips ToBounds 属性为 NO, 这样超过父视图 bound 区域的视图的内容也会显示),那么正常情况下对子视图在父视图之外区域的触摸操作不会被父视图识别,由于父视图的 pointInSide:withEvent:方法会返回 NO, 这样子就不会继续向下便利子视图了.当然也能够重写pointInSide:withEvent:方法 来处理这样的情况.

iOS 事件传递及响应过程的更多相关文章

  1. iOS事件传递->处理->响应

    前言: 按照时间顺序,事件的生命周期是这样的: 事件的产生和传递(事件如何从父控件传递到子控件并寻找到最合适的view.寻找最合适的view的底层实现.拦截事件的处理)->找到最合适的view后 ...

  2. iOS 点击事件传递及响应

    1.iOS中的事件 iOS中的事件可以分为3大类型: 触摸事件 加速计事件 远程控制事件这里我们只讨论iOS中的触摸事件. 1.1响应者对象(UIResponder) 在iOS中不是任何对象都能处理事 ...

  3. iOS事件传递&响应者链条

    原文:http://www.cnblogs.com/Quains/p/3369132.html 主要是记录下iOS的界面触摸事件处理机制,然后用一个实例来说明下应用场景. 一.处理机制 界面响应消息机 ...

  4. iOS事件传递和事件响应者链 20170810

    一.事件响应者链 事件传递和事件响应链 区别 事件的传递和响应的区别: 事件的传递是从上到下(父控件到子控件),事件的响应是从下到上(顺着响应者链条向上传递:子控件到父控件. 引出 当我们手指触摸屏幕 ...

  5. iOS 事件传递(Touch事件)

    先总说如下: 1.当手指触摸到屏幕时,会产生UITouch对象和UIEvent对象. 2.这两个对象产生后会被传递到UIApplication管理的一个事件队列中. 3.再有UIApplication ...

  6. ios事件传递

    http://blog.csdn.net/iefreer/article/details/4754482 本章描述了iPhone操作系统里的事件类型,并解释了如何处理它们.还讨论了怎么在一个应用程序里 ...

  7. iOS 事件传递响应链

    iOS中加载的时候会先执行main函数 int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain( ...

  8. Event Delivery: The Responder Chain(事件传递,响应链)

    当我们设计app的时候,我们很可能想动态的响应事件.例如,触摸一个拥有许多不同对象的屏幕,你要决定给哪个对象一个响应事件,怎么样对象接收到事件. 当一个用户产生事件发生时(如 点击),UIKit产生一 ...

  9. iOS-UIResponse之事件响应链及其事件传递

    UIResponse之事件响应链及其事件传递 我们的App与用户进行交互,基本上是依赖于各种各样的事件.一个视图是一个事件响应者,可以处理点击等事件,而这些事件就是在UIResponder类中定义的. ...

随机推荐

  1. CareerCup之1.3字符串去重

    [题目] 原文: 1.3 Design an algorithm and write code to remove the duplicate characters in a string witho ...

  2. ios项目开发(天气预报项目):使用正则获取 weather.com.cn站点信息

    NSString *pattern = @"(?<=<td class=\"bigblod\">).*?(?=</td>)"; 2 ...

  3. 5V and 3V Level Translators

    http://www.daycounter.com/Circuits/Level-Translators/Level-Translators.phtml Interfacing 5V and 3V l ...

  4. redhat server 5.3内核升极2.6.18 升级到 3.5 装systemtap 原创

    1. 在 LINUX 3.5源代码目录下执行  yum install ncurses-devel     make menuconfig 2  打开内核跟踪事件,用于SYSTEMTAP跟踪 kern ...

  5. 【windows socket+HTTPserverclient】

    Windows Socket+HTTPserverclient      Winsock是 Windows下套接字标准.                 1.HTTP协议:          HTTP ...

  6. 你得学会并且学得会的Socket编程基础知识(续)——Silverlight客户端

    本文将在这个案例的基础上,加入一个特殊场景,利用Silverlight来实现客户端.有的朋友可能会说,其实是一样的吧.请不要急于下结论,有用过Silverlight的朋友都有这种体会,很多在标准.NE ...

  7. Bootstrap 3之美03-独立行,文字环绕,图片自适应,隐藏元素

    本篇主要包括: ■  添加独立的一行■  文字环绕■  图片自适应■  隐藏元素 添加独立的一行 在id为body的section和id为main的section之间,添加2张图片. 我们发现,新加的 ...

  8. Bootstrap 3之美02-Grid简介和应用

    本篇主要包括: ■  Grid简介■  应用Grid■  Multiple Grids Grid简介 Bootstrap中,把页面分成12等份,这就是所谓的Grid. 在Bootstrap中,用类名控 ...

  9. Leader之重

    1:合理安排每个CASE并检查每个人每天的工作进度和质量: 这会让一个庞大的工作,或者看上不可能完成的任务,变成可完成的.   2:警惕对立情绪,并寻找交接者: 永远无法控制所有成员对你或者对团队对公 ...

  10. Redis:ERR operation not permitted

    Redis服务开启之后: D:\Redis\redis>redis-server.exe redis.conf 那么另外开一个命令窗口 D:\Redis\redis>redis-cli.e ...