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类中定义的. ...
随机推荐
- [重要更新][Quartus II][14.1正式版]
[Quartus II][14.1正式版] ----14.1版本最大的变化就是增加了2大系列的器件库: MAX 10和Arria 10.这2大系列据Altera中国区代理 骏龙科技的人说,就是为了和X ...
- 【Go入门教程6】struct类型(struct的匿名字段)
struct Go语言中,也和C或者其他语言一样,我们可以声明新的类型,作为其它类型的属性或字段的容器.例如,我们可以创建一个自定义类型person代表一个人的实体.这个实体拥有属性:姓名和年龄.这样 ...
- Latex Error cannot determine the size of graphic 报错的解决的方法
Latex Error cannot determine the size of graphic 报错的解决的方法 插入jpg文件老是会报错... 追究了半天,原来是编译的命令又问题,不应该使用 la ...
- 点赞和吐糟Adblock Plus~进阶教程
前言:Adblock Plus后文都简称ABP,这是一篇ABP进阶教程!用ABP实现flashBlock和NoScript.推荐有相当基础的阅读.刚開始学习的人先看懂这里:http://adblock ...
- iOS内存优化及排查方法
1.IBOutlet 对象需要release 2.不停的往UIView,特别是UIScrollView上add相同SubView.一定要记得清除之前的SubView,并且在dealloc函数中执行该方 ...
- 高手写的“iOS 的多核编程和内存管理”
原文地址:http://anxonli.iteye.com/blog/1097777 多核运算 在iOS中concurrency编程的框架就是GCD(Grand Central Dispatch), ...
- ffmpeg 2.3版本号, 关于ffplay音视频同步的分析
近期学习播放器的一些东西.所以接触了ffmpeg,看源代码的过程中.就想了解一下ffplay是怎么处理音视频同步的,之前仅仅大概知道通过pts来进行同步,但对于怎样实现却不甚了解,所以想借助这个机会, ...
- Qt5设置应用程序图标
1.设置应用程序图标 简单三步走,搞定 ①创建一个图标格式的文件,可以网上在线将普通的图形格式转成.ico 格式的图标文件 http://www.faviconico.org/ 这个网站可以在线转换p ...
- 第二章 Jackson属性名转换+属性忽略
@Data @JsonIgnoreProperties(ignoreUnknown = true) public class MyRecord { private boolean succeed; p ...
- WebChromeClient 简介 API 案例
代码位置:https://github.com/baiqiantao/WebViewTest.git 设计思想理解 在WebView的设计中,不是什么事都要WebView类干的,有相当多的杂事是分给其 ...