类型"NSNotification.Name"没有成员"keyboardDidShowNotification" [英] Type 'NSNotification.Name' has no member 'keyboardDidShowNotification'
本文介绍了类型"NSNotification.Name"没有成员"keyboardDidShowNotification"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Swift 4.2中遇到此错误
I'm getting this error with Swift 4.2
类型"NSNotification.Name"没有成员"keyboardDidShowNotification"
Type 'NSNotification.Name' has no member 'keyboardDidShowNotification'
这是我的代码:
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardDidShow(notification:)), name: NSNotification.Name.keyboardDidShowNotification, object: nil)
以下一项在Swift 4上运行正常,但在Swift 4.2上运行不正常
Following one was working fine with Swift 4 but not with Swift 4.2
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardDidShow(notification:)), name: NSNotification.Name.UIKeyboardDidShow, object: nil)
Apple文档参考: NSNotification.Name.keyboardDidShowNotification
Apple document Ref: NSNotification.Name.keyboardDidShowNotification
推荐答案
我相信您现在就这样使用它.
I believe you use it like this now.
NotificationCenter.default.addObserver(
self,
selector: #selector(self.keyboardDidShow(notification:)),
name: UIResponder.keyboardDidShowNotification, object: nil)
/* You can substitute UIResponder with any of it's subclass */
它在UIResponder
doc 中列为类型属性.
这篇关于类型"NSNotification.Name"没有成员"keyboardDidShowNotification"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文