firstResponder
https://developer.apple.com/library/content/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/DirectingInputtoaSpecificResponder.html#//apple_ref/doc/uid/TP40009541-CH12-SW1
Directing Input to a Specific Responder
Touch events are automatically dispatched to the view in which they occurred, but most other events are directed to the object designated as the first responder. You can also set the first responder programmatically to any of your app’s responder objects. User interactions may also cause a view to become the first responder automatically, but only if it wants to be the first responder. For example, tapping a text field causes the text field to become the first responder, but tapping a button triggers the button’s action and does not cause it to become the first responder.
When an object becomes the first responder, UIKit displays the input view associated with that responder. An input view is a custom interface that you can use to gather information. The system keyboard is an example of an input view.
Programmatically Changing the First Responder
To designate an object as the first responder, call its becomeFirstResponder method. UIKit makes the object the first responder only if the following conditions are met:
The current first responder’s
canResignFirstResponderproperty returnsYES.The new responder’s
canBecomeFirstResponderproperty returnsYES. (The default implementation of this property returnsNO, so you must override it to allow your object to become the first responder.)
Most responder objects resign the first responder status readily, but you can return NO as needed from the canResignFirstResponder property. For example, you might return NO to prevent your custom control from resigning as first responder while it contains invalid data.
firstResponder的更多相关文章
- 解析iOS开发中的FirstResponder第一响应对象
1. UIResonder 对于C#里所有的控件(例如TextBox),都继承于Control类.而Control类的继承关系如下: 代码如下: System.Object System.Marsha ...
- (转)FirstResponder 释放问题
FirstResponder 释放问题 转自:http://www.cnblogs.com/smileEvday/archive/2012/03/18/2405190.html View的FirstR ...
- iOS 委托与文本输入(内容根据iOS编程编写)
文本框(UITextField) 本章节继续编辑 JXHypnoNerd .文件地址 . 首先我们继续编辑 JXHypnosisViewController.m 修改 loadView 方法,向 ...
- iOS开发常用代码块
遍历可变数组的同时删除数组元素 NSMutableArray *copyArray = [NSMutableArray arrayWithArray:array]; NSString *str1 = ...
- ios开发中的小技巧
在这里总结一些iOS开发中的小技巧,能大大方便我们的开发,持续更新. UITableView的Group样式下顶部空白处理 //分组列表头部空白处理 UIView *view = [[UIViewal ...
- iOS对键盘的处理
方法1. 使用<UITextFeildDelegate>,使用的UITextField示例 设置其Delegate为self,点击return按钮隐藏键盘.实现函数如下: - (BO ...
- 深入浅出iOS事件机制
原文地址: http://zhoon.github.io/ios/2015/04/12/ios-event.html 本文章将讲解有关iOS事件的传递机制,如有错误或者不同的见解,欢迎留言指出. iO ...
- [转]iOS7中UITextView contentsize改变时机
在iOS7以下版本中,对UITextView设置了text属性,则contentsize就会变化,从而可以根据contentsize的变化来改变UITextView高度来做出TextView高度随着输 ...
- iOS小技巧总结,绝对有你想要的
原文链接 在这里总结一些iOS开发中的小技巧,能大大方便我们的开发,持续更新. UITableView的Group样式下顶部空白处理 //分组列表头部空白处理 UIView *view = [[UIV ...
随机推荐
- PyInstaller把Python脚本打包成可执行程序教程
一.说明 一直以来都有把.py文件打包成.exe文件的想法,但总是不够强烈,每次拖着拖着就淡忘了. 昨天帮硬件部门的同事写了个脚本,然后今天下午的时候,他问有没有办法把脚本打包成可执行文件,这样方便以 ...
- Java 中将字符串数组转换为字符串
Java 中将字符串数组转换为字符串 import java.util.Arrays; import java.util.HashSet; import java.util.Set; public c ...
- Flink 源码解析 —— 项目结构一览
Flink 源码项目结构一览 https://t.zsxq.com/MNfAYne 博客 1.Flink 从0到1学习 -- Apache Flink 介绍 2.Flink 从0到1学习 -- Mac ...
- Linux指定运行级别,帮助指令(man,help)
运行级别说明: 0:关机 1:单用户[找回丢失密码] 2:多用户状态[无网络服务] 3:多用户状态[有网络服务] 4:保留级别 5:图形界面 6:系统重启 一.指定运行级别 1.修改默认运行级别 vi ...
- 『正睿OI 2019SC Day3』
容斥原理 容斥原理指的是一种排重,补漏的计算思想,形式化的来说,我们有如下公式: \[\left | \bigcup_{i=1}^nS_i \right |=\sum_{i}|S_i|-\sum_{i ...
- 【java】java 读写文件
场景:JDK8 将上传的文件,保存到服务器 Java读写文件操作: MultipartFile file InputStream inputStream = file.getInputStream( ...
- Flink基本的API
Flink使用 DataSet 和 DataStream 代表数据集.DateSet 用于批处理,代表数据是有限的:而 DataStream 用于流数据,代表数据是无界的.数据集中的数据是不可以变的, ...
- maven中pom的继承以及dependencies与dependencyManagement的区别
https://blog.csdn.net/zzm3280/article/details/84952623 分类专栏: maven 本文转自:https://blog.csdn.net/liut ...
- C# GDI graphics.DrawImage 的参数问题
graphics.DrawImage(imageSource, new System.Drawing.Point[] { ,), , ), , ), } ); graphics.DrawImage(i ...
- 将fileupload标签的值清空
在开发中遇到了这样一个问题,在一个form表单中,有一个fileupload标签,新增,修改都是同一个form,当我第一次选择了上传文件路径,并且提交之后,第二次再使用这个form,这次没有选择上传文 ...