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

推荐订阅源

P
Proofpoint News Feed
D
DataBreaches.Net
雷峰网
雷峰网
WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
F
Fortinet All Blogs
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Engineering at Meta
Engineering at Meta
月光博客
月光博客
V
Visual Studio Blog
美团技术团队
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
博客园 - 【当耐特】
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 聂微东

博客园 - 墨墨

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