惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
量子位
N
Netflix TechBlog - Medium
M
MIT News - Artificial intelligence
GbyAI
GbyAI
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
Y
Y Combinator Blog
L
LangChain Blog
The Cloudflare Blog
T
The Blog of Author Tim Ferriss
U
Unit 42
Martin Fowler
Martin Fowler
aimingoo的专栏
aimingoo的专栏
G
Google Developers Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客

博客园 - 墨墨

Windows Phone 7中配置gmail, 使用outlook 同步邮件,日历,联系人等 iPhone 闭包应用 iPhone屏幕旋转的例子 第一个iPhone程序之Hello World 第一个objective-c程序 iPhone自动化测试 visual studio 2010 ultimate 下载 suse下设置IP的两种方法 freebsd下之简单安装python ibatis.net私人学习资料,勿下(加密) ibatisnet高级查询 Python相关中文学习资料 搭建python的web开发环境 windows下 使用Aptana搭建Python开发环境 使用SharpZipLib 解压zip 2012年真的是世界末日吗?_全球关注 关于生成静态页--终极解决方案 Json格式类的转换相关代码 Extjs 登录界面源码
objective-c的TextFields输入完成后关闭键盘和触摸背景关闭键盘
墨墨 · 2010-10-21 · via 博客园 - 墨墨

首先输入完成后按键盘上的done关闭键盘

首先在Interface Builder中选择TextFields,然后在Text Field Attributes中找到Text Input Traits,选择Return Key为done。OK

定义方法

- (IBAction) textFieldDoneEditing:(id)sender; //按下Done键关闭键盘

实现方法

//按完Done键以后关闭键盘

- (IBAction) textFieldDoneEditing:(id)sender

{

[sender resignFirstResponder];

}

然后找到事件Did End On Exit,与textFieldDoneEditing关联,OK。 

如果是数字键盘,没有done键怎么办呢,我们通过触摸背景关闭键盘

定义方法

- (IBAction) backgroundTap:(id)sender; //通过触摸背景关闭键盘

实现方法

//通过触摸背景关闭键盘

- (IBAction) backgroundTap:(id)sender

{

[nameFiled resignFirstResponder];

[numberField resignFirstResponder];

}

然后选择背景的Touch Down事件,关联 backgroundTap,OK