iOS 事件传递及响应过程
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 事件传递及响应过程的更多相关文章
- iOS事件传递->处理->响应
前言: 按照时间顺序,事件的生命周期是这样的: 事件的产生和传递(事件如何从父控件传递到子控件并寻找到最合适的view.寻找最合适的view的底层实现.拦截事件的处理)->找到最合适的view后 ...
- iOS 点击事件传递及响应
1.iOS中的事件 iOS中的事件可以分为3大类型: 触摸事件 加速计事件 远程控制事件这里我们只讨论iOS中的触摸事件. 1.1响应者对象(UIResponder) 在iOS中不是任何对象都能处理事 ...
- iOS事件传递&响应者链条
原文:http://www.cnblogs.com/Quains/p/3369132.html 主要是记录下iOS的界面触摸事件处理机制,然后用一个实例来说明下应用场景. 一.处理机制 界面响应消息机 ...
- iOS事件传递和事件响应者链 20170810
一.事件响应者链 事件传递和事件响应链 区别 事件的传递和响应的区别: 事件的传递是从上到下(父控件到子控件),事件的响应是从下到上(顺着响应者链条向上传递:子控件到父控件. 引出 当我们手指触摸屏幕 ...
- iOS 事件传递(Touch事件)
先总说如下: 1.当手指触摸到屏幕时,会产生UITouch对象和UIEvent对象. 2.这两个对象产生后会被传递到UIApplication管理的一个事件队列中. 3.再有UIApplication ...
- ios事件传递
http://blog.csdn.net/iefreer/article/details/4754482 本章描述了iPhone操作系统里的事件类型,并解释了如何处理它们.还讨论了怎么在一个应用程序里 ...
- iOS 事件传递响应链
iOS中加载的时候会先执行main函数 int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain( ...
- Event Delivery: The Responder Chain(事件传递,响应链)
当我们设计app的时候,我们很可能想动态的响应事件.例如,触摸一个拥有许多不同对象的屏幕,你要决定给哪个对象一个响应事件,怎么样对象接收到事件. 当一个用户产生事件发生时(如 点击),UIKit产生一 ...
- iOS-UIResponse之事件响应链及其事件传递
UIResponse之事件响应链及其事件传递 我们的App与用户进行交互,基本上是依赖于各种各样的事件.一个视图是一个事件响应者,可以处理点击等事件,而这些事件就是在UIResponder类中定义的. ...
随机推荐
- 关于maven依赖中的<scope>provided</scope>使用
今天开发web的时候,需要用到servlet-api,于是在pom.xml中添加依赖 <dependency> <groupId>javax.servlet</group ...
- MVC扩展Filter,通过继承ActionFilterAttribute为登录密码加密
与ActionFilter相关的接口有2个: □ IActionFilter 对action执行前后处理 void OnActionExecuting(ActionExecutingContext f ...
- [翻译] 使用开源库 JGDownloadAcceleration 控制下载队列,断点下载,加速下载
JGDownloadAcceleration 本人对原文进行了翻译,凑合看看,使用心得以后补上 https://github.com/JonasGessner/JGDownloadAccelerati ...
- Tomcat 7 的七大新特性
英文原文:Top 7 Features in Tomcat 7: The New and the Improved Tomcat的7引入了许多新功能,并对现有功能进行了增强.很多文章列出了Tomcat ...
- 异常:javax.el.PropertyNotFoundException: Property 'id' not found on ..........
在后台action中查询数据库返回的UserInfo对象后 将uDisplayName传递到jsp中,jsp中用${userInfo.uDisplayName}接收值时报错: 异常:javax.el. ...
- 操作系统的启动与引导问题 BIOS、UEFI、MBR、GPT
关于ISO.WIM.GHO三者的正确理解. ISO(Isolation)文件一般以ISO为扩展名,是复制光盘上全部信息而形成的镜像文件. WIM是英文Microsoft Windows Imaging ...
- ORA-12560: TNS: 协议适配器错误的解决方法
ORA-12560: TNS: 协议适配器错误的解决方法 造成ORA-12560: TNS: 协议适配器错误的问题的原因有三个: 1.监听服务没有起起来.windows平台个一如下操作:开始---程序 ...
- mahout源码KMeansDriver分析之四
昨天说到为什么Configuration没有设置conf.set("mapred.job.tracker","hadoop:9000")仍然可以访问hdfs文件 ...
- Sort List leetcode java
题目: Sort a linked list in O(n log n) time using constant space complexity. 题解: 考虑到要求用O(nlogn)的时间复杂度和 ...
- AS 代码模板 文件模板 Templates MD
修改 File and Code Templates Settings –> Editor –>[File and Code Templates] 或者在右键new时选择子菜单[Edite ...