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
canResignFirstResponder
property returnsYES
.The new responder’s
canBecomeFirstResponder
property 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 ...
随机推荐
- Js迷宫游戏
<!DOCTYPE html> <html> <head> <title>MyHtml.html</title> </head> ...
- vue-router学习笔记(一)
学习vue-router首先要认识的两个属性 $router 和 $route. $router指的是router实例,$route则是当前激活的路由信息对象,是只读属性,不可更改,但是可以watch ...
- SpringBoot扩展点之一:SpringApplicationRunListener
三种监听器的关系 ApplicationListener.SpringApplicationRunListeners.SpringApplicationRunListener的关系: SpringAp ...
- Docker的安装与使用
Docker的安装 (1)卸载老版本yum remove docker \ docker-client \ docker-clien ...
- 『2019Summer Algorithms』
一个暑假两次集训,感觉学了好多好多的东西,也挖了好多好多的坑,于是就决定写一篇关于算法的总结,用于熟悉新算法,也留下一点对新算法的理解. AC自动机 简单的说就是在\(trie\)树上实现\(KMP\ ...
- MQTT --- 操作行为
会话状态 为实现QoS等级1和QoS等级2协议流,客户端和服务端需要将状态与客户标识符相关联,这被称为会 话状态.服务端还将订阅信息存储为会话状态的一部分.会话可以跨越一系列的网络连接.它持续到最新的 ...
- css元素水平垂直居中
温习一下元素水平垂直居中的几种方法 元素有具体宽度 1.absolute+负边距 .LV_center{ border: 1px solid red; position: absolute; widt ...
- IDEA超级实用的几个快捷键
最近开始使用IDEA,突然发现的比较的实用的几个快捷键 这些快捷键用的好的话真的可以提升很多效率 还有一些比较简单的快捷键,相信大家都会 Ctrl+X:剪切 Ctrl+C:复制 Ctrl+V:粘贴 C ...
- 实现SpringCloud Config 客户端自动刷新
文章来源:https://blog.csdn.net/qq_27385301/article/details/82716218 一.简介 在使用SpringCloud Config客户端时,如果Con ...
- Promise介绍及使用场景
Promise 介绍 Promise 是一个构造函数,是异步编程的一种解决方案.所谓Promse,它本身就是一个容器,里面保存着异步操作的结果,对的,这和回调函数类似. Promise 容器本身不是异 ...