【发布时间】:2019-02-18 08:44:15
【问题描述】:
我在使用 Swift 4.2 时遇到此错误
类型“NSNotification.Name”没有成员“keyboardDidShowNotification”
这是我的代码:
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardDidShow(notification:)), name: NSNotification.Name.keyboardDidShowNotification, object: nil)
以下一个在 Swift 4 上运行良好,但在 Swift 4.2 上运行良好
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardDidShow(notification:)), name: NSNotification.Name.UIKeyboardDidShow, object: nil)
【问题讨论】:
-
与您的“按钮类型”问题一样...@Krunal-这可能会有所帮助...(不是我的,我还没有尝试过...只是通过搜索找到的):@ 987654323@
-
@DonMag - 谢谢。这是很不错的。但看起来像是对 Swift4.2 的补丁/支持。我正在迁移我的完整项目。
-
当然...但是该要点可能对于这些类型的语法更改是一个不错的参考。至于迁移整个项目,Xcode 10确实有一个迁移助手可能会有所帮助。参考:swift.org/migration-guide-swift4.2
标签: ios keyboard-events nsnotificationcenter swift4.2