UIResponder详解
UIResponder Class Reference
Managing the Responder Chain
- 1.- (UIResponder *)nextResponder
返回接收者的下一个相应,如果没有就返回nil
UIResponder类不自动存储和设置下一个响应者,而是默认返回nil。子类必须override这个方法来设置下一个响应者。
UIView实现了这个方法,因为可以返回管理这个UIView的UIViewController或者它的父类;
UIViewController实现了这个方法,返回UIViewController的View的父View;
UIWindow发挥UIApplication对象;
UIApplication返回nil
- 2.- (BOOL)isFirstResponder
判断一个对象是否是第一响应者。
- 3.- (BOOL)canBecomeFirstResponder
判断一个对象是否可以成为第一响应者。默认返回NO。
如果一个响应对象通过这个方法返回YES,那么它成为了第一响应对象,并且可以接收触摸事件和动作消息。
子类必须overrider这个方法才可以成为第一响应者。
You must not send this message to a view that is not currently attached to the view hierarchy. The result is undefined.
- 3.- (BOOL)becomeFirstResponder
如果接收者接受了第一响应者的状态就返回YES,拒绝了这个状态就返回NO。默认返回YES。
子类可以override这个方法来更新状态或者执行一些行为,比如高亮选中项。
一个响应对象只有当前响应者可以放弃第一响应者状态,并且新的响应者可以成为第一响应者,才能成为第一响应对象。
- 4.- (BOOL)canResignFirstResponder
如果一个对象可以放弃对象响应者就返回YES。默认返回YES。
- 5.- (BOOL)resignFirstResponder
默认实现返回YES,放弃第一响应状态。子类可以override这个方法来更新状态或者执行一些行为,比如取消高亮选中项。
如果返回NO,拒绝放弃第一响应状态。
如果你override这个方法,必须调用父类的实现[super resignFirstResponder].
Managing Input Views
- 1.@property (readonly, retain) UIView *inputView
当一个对象变成第一响应者的时候显示的View
This property is typically used to replace the system-supplied keyboard that is presented for
UITextField and UITextView objects.
UITextField和UITextView如果设置了inputView那么在
becomeFirstResponder时不会显示键盘,而现实自定义的inputView;如果设置了inputAccessoryView那么在
becomeFirstResponder时会在键盘的顶端显示自定义的inputAccessoryView。
- 2.@property (readonly, retain) UIView *inputAccessoryView
This property is typically used to attach an accessory view to the system-supplied keyboard that is presented for
UITextField and UITextView objects.
- 3.- (void)reloadInputViews
当对象成为第一响应者的时候更新inputView和accessoryView。
Responding to Touch Events
- 1.- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
通知接收者当一个或多个手指在UIView或UIWindow上点下了。
将消息转发给下一个响应者,将消息发送给父类,不要将消息直接传递给下一个响应者。
如果你override这个方法而没有调用super..,你必须同样override其它响应触摸事件的方法,你要是空实现就好。
默认是不支持多点触摸的,如果想要响应多点触摸,你只要吧UIView的 multipleTouchEnabled 属性设置为YES即可。
- 2.- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
手指移动
- 3.- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
手指抬起
- 4.- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
当收到一个系统干扰需要取消触摸事件时才会调用该方法,这种系统干扰往往会引起应用程序长时间没有响应或者一个View从window上移除了。
Responding to Motion Events
- 1.- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
通知接收者一个动作开始了。
- 2.- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
通知接收者一个动作结束了。
- 3.- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
一个动作被取消了。雷同- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
Responding to Remote-Control Events
- 1.- (void)remoteControlReceivedWithEvent:(UIEvent *)event
接收到一个远程控制事件。比如耳机控制。
Getting the Undo Manager
- 1.@property(readonly) NSUndoManager *undoManager
返回在响应链中最近的共享undo manager。
Validating Commands
- 1.- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
YES if the the command identified by action should be enabled or
NO if it should be disabled. Returning YES means that your class can handle the command in the current context.
UIResponder详解的更多相关文章
- iOS学习——(转)UIResponder详解
本文转载自:ios开发 之 UIResponder详解 我们知道UIResponder是所有视图View的基类,在iOS中UIResponder类是专门用来响应用户的操作处理各种事件的,包括触摸事件( ...
- iOS学习之UINavigationController详解与使用(一)添加UIBarButtonItem
http://blog.csdn.net/totogo2010/article/details/7681879 1.UINavigationController导航控制器如何使用 UINavigati ...
- 详解CALayer 和 UIView的区别和联系
详解CALayer 和 UIView的区别和联系 前言 前面发了一篇iOS 面试的文章,在说到 UIView 和 CALayer 的区别和联系的时候,被喵神指出没有切中要点,所以这里就 CALay ...
- UINavigationController详解一(转)UIBarButtonItem
本文出自:http://www.cnblogs.com/smileEvday/archive/2012/05/14/2495153.html 特别感谢. 1.UINavigationControlle ...
- iOS中—触摸事件详解及使用
iOS中--触摸事件详解及使用 (一)初识 要想学好触摸事件,这第一部分的基础理论是必须要学会的,希望大家可以耐心看完. 1.基本概念: 触摸事件 是iOS事件中的一种事件类型,在iOS中按照事件划分 ...
- Bmob第三方登录详解
Bmob第三方登录详解 Bmob 第三方登录 简介 本文主要介绍新浪微博,QQ,微信的登录接入以及如何配合BmobSDK中的第三方登录功能实现第三方登录. 在使用之前请先按照快速入门创建好可以调用Bm ...
- iOS开发——UI篇OC篇&SpriteKit详解
SpriteKit详解 SpriteKit,iOS/Mac游戏制作的新纪元 这是我的WWDC2013系列笔记中的一篇,完整的笔记列表请参看这篇总览.本文仅作为个人记录使用,也欢迎在许可协议范围内转载或 ...
- iOS应用开发详解
<iOS应用开发详解> 基本信息 作者: 郭宏志 出版社:电子工业出版社 ISBN:9787121207075 上架时间:2013-6-28 出版日期:2013 年7月 开本:16开 ...
- IOS 触摸事件分发机制详解
欢迎大家前往云+社区,获取更多腾讯海量技术实践干货哦~ 作者:MelonTeam 前言 很多时候大家都不关心IOS触摸事件的分发机制的实现原理,当遇到以下几种情形的时候你很可能抓破头皮都找不到解决方案 ...
随机推荐
- 一场BC的台前幕后
#define BC BestCoder 一场BC的台前幕后 起源大概是这种:一个月前的BC#75结束后,AK的人非常多,于是CodeVS群里非常多人吐槽BC#75的质量,这时YJQ对KPM说:&qu ...
- C#之线程和线程池(Thread和ThreadPool类)
注:要使用此方法都需要引入应用:using System.Threading;//引入应用 参数意义:将要执行的方法排入队列以便执行,WaitCallback,即表示将要执行的方法:Object,包含 ...
- Android开源框架ViewPageIndicator和ViewPager实现Tab导航
前言: 关于使用ViewPageIndicator和ViewPager实现Tab导航,在开发社区里已经有一堆的博客对其进行了介绍,假设我还在这里写怎样去实现.那简直就是老生常谈,毫无新奇感,并且.我也 ...
- vue cli webstorm
贫富差距的产生 – 目光博客 http://eyehere.net/2017/1947/ https://github.com/vuejs/vue Vue 2.0 Hello World - JSFi ...
- 又发现2个高人写的Delphi图文并茂的消息研究
http://ymg97526.blog.163.com/blog/static/173658160201139101120862/http://ymg97526.blog.163.com/blog/ ...
- X86架构下Linux启动过程分析
1.X86架构下的从开机到Start_kernel启动的整体过程 这个过程简要概述为: 开机-->BIOS-->GRUB/LILO-->Linux Kernel 其执行的流程图和重要 ...
- unpe13e 学习备忘1
转其他地方. http://blog.sina.com.cn/s/blog_a43aba560101a2s5.html 运行书本中的程序.1,首先,下载源码:unpv13e.tar.gz2,然后,编 ...
- codeforces 939E Maximize! 双指针(two pointers)
E. Maximize! time limit per test 3 seconds memory limit per test 256 megabytes input standard input ...
- POJ 2195 Going Home 最小费用流
POJ2195 裸的最小费用流,当然也可以用KM算法解决,但是比较难写. 注意反向边的距离为正向边的相反数(因此要用SPFA) #include<iostream> #include< ...
- LuaBridge
不能直接公开基类的函数,必须单独公开基类,并声明继承关系 deriveClass<Player, BaseController>("Player") 直接公开基类的函 ...