我过去曾经用过这个.
override func touchesBegan(touches: Set<UITouch>,withEvent event: UIEvent?) { self.view.endEditing(true) }
但现在在Xcode 8 beta中我收到此错误:
声明touchBegan(touches:withEvent)具有来自任何潜在覆盖的不同参数名称.
有什么想法吗?
解决方法
这对我有用:
override func touchesBegan(_ touches: Set<UITouch>,with event: UIEvent?) { self.view.endEditing(true) }
请注意函数参数中非常微妙的Swift 3更新.在The Swift Programming Language (Swift 3)页的第20页和第21页,他们解释说:
“By default,functions use their parameter names as labels for their arguments. Write a custom argument label before the parameter name,or write _ to use no argument label.”