使用 swift 删除键盘

removing keyboard with swift

我想在完成打字后通过单击开箱即用的任意位置来移除键盘,所以我写了这个

 override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent!) {
        self.view.endEditing(true)
    }

但它说我没有覆盖晚饭中的任何方法-class.But怎么会这样?:)

对于 Swift 2,使用:

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?)