Nffish's Blog

好记性不如烂笔头

Posts Tagged ‘关闭键盘’

iPhone的键盘是基于软件,而不是物理键盘的,因此需要一些额外的步骤来确保用户在完成输入后关闭键盘。 1.通过点击Done按钮关闭键盘 当用户按下Done按钮式,将触发“did end on exit”事件,我们可以在此时间中加入关闭键盘的操作。 在头文件中加入 -(IBAction)textFieldDoneEditing:(id)sender; 在实现文件中添加 -(IBAction)textFieldDoneEditing:(id)sender { [sender resignFirstResponder]; } 在Interface Builder中按command+2 选择文本字段的Did End on Exit事件,拖动到File’s…