【发布时间】:2015-11-14 00:33:04
【问题描述】:
我想在完成输入后通过单击框外的任何位置来移除键盘,所以我写了这个
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent!) {
self.view.endEditing(true)
}
但它说我没有覆盖晚餐类的任何方法。但是怎么办?:)
【问题讨论】:
我想在完成输入后通过单击框外的任何位置来移除键盘,所以我写了这个
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent!) {
self.view.endEditing(true)
}
但它说我没有覆盖晚餐类的任何方法。但是怎么办?:)
【问题讨论】:
对于 Swift 2,使用:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?)
【讨论】: