ios – Xcode 8 – 当用户点击背景时,键盘会消失

ios – Xcode 8 – 当用户点击背景时,键盘会消失,第1张

概述我过去曾经用过这个. 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>,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.”

总结

以上是内存溢出为你收集整理的ios – Xcode 8 – 当用户点击背景时,键盘会消失全部内容,希望文章能够帮你解决ios – Xcode 8 – 当用户点击背景时,键盘会消失所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1030184.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存