如何用Apple的新语言实现它?
Objective-C代码:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { for (UIView *view in self.view.subviews) [view resignFirstResponder]; }
我试图这样做.但是键盘并没有消失:
SWIFT代码:
override func touchesBegan(touches: NSSet,withEvent event: UIEvent) { super.touchesBegan(touches,withEvent: event) self.view.resignFirstResponder() }
你可能会去:
self.view.endEditing(true)