在iphone模拟器使用后,我如何隐藏键盘?在我的应用程序中,它的文本字段是名称,另一个是密码和一个按钮,当我点击按钮时,我想隐藏键盘。
发布于 2010-05-05 19:55:30
在按钮动作例程中编写yourTextField resignFirstResponder。它会隐藏你的键盘。
吉姆。
发布于 2010-05-05 19:55:29
有两种方法可以做到这一点。
1>实现
- (IBAction) doneButtonOnKeyboardPressed: (id)sender
{
}Textfield的Did方法在退出事件时结束
或
在Textfield中实现此委托方法
-(BOOL)textFieldShouldReturn:(UITextField *)theTextField {
[txtName resignFirstResponder];
return YES;
}发布于 2013-02-07 23:08:41
好的,如果我们想要在UITextView (名字为"myTextView")之外点击鼠标时关闭模拟器的键盘,我们可以使用:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
self.myTextView.resignFirstResponder;
// or [myTextView resignFirstResponder];
}https://stackoverflow.com/questions/2772894
复制相似问题