如何使用Apple的新语言实现它:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
for (UIView *view in self.view.subviews)
[view resignFirstResponder];
}
我试过这样做。但键盘并没有消失:
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
super.touchesBegan(touches, withEvent: event)
self.view.resignFirstResponder()
}
答案 0 :(得分:47)
你可以选择:
self.view.endEditing(true)
答案 1 :(得分:3)
试试这个
self.view.endEditing(true)