我的应用程序中有导航 Controller 和工具栏。在工具栏中是通过操作“显示详细信息”显示 TableView Controller 的栏项。当我单击取消并关闭此 TableView 时,键盘会等待直到 TableView Controller 完全关闭。我想将键盘与表格 View 一起关闭。
这是我的“取消操作”按钮:
@IBAction func cancelTapped(sender: AnyObject) {
self.nameTextField.becomeFirstResponder()
self.caffeineTextField.becomeFirstResponder()
self.dismissViewControllerAnimated(true, completion: nil)
}
最佳答案
您正在制作文本字段 First Responder,以便键盘保持打开状态。你应该 resignefirstResponder 从这些。其他关闭键盘的好方法是:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[[self view] endEditing:YES];
}
关于ios - 如何在没有动画的情况下隐藏键盘(或加速此动画),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28672781/