我最近升级到最新的Xcode版本并将我的项目转换为Swift 2.3。直到2.2,当我显示UIAlertController
时,我用经典
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?){
view.endEditing(true)
super.touchesBegan(touches, withEvent: event)
}
嗯,它不再起作用了。试图更改textView的UIKeyboardType
和returnKeyType
。没运气。有什么想法吗?
答案 0 :(得分:0)
尝试为视图使用tapGesture Recognizer。试试这个link
或者您可以试用此代码:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?)
{
super.touchesBegan(touches, withEvent: event)
view.endEditing(true)
}
希望这会帮助你。快乐的编码