【发布时间】:2019-02-27 04:29:18
【问题描述】:
以下代码在 Swift 4.2 之前运行良好:
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChange(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
当我点击“修复”选项时,它变成:
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChange(notification:)), name: NSNotification.Name.UIResponder.keyboardWillShowNotification, object: nil)
但它仍然被标记为错误。解释如下:
Type 'NSNotification.Name' has no member 'UIResponder'
然后我尝试删除“UIResponder”:
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChange(notification:)), name: NSNotification.Name.
...但我不知道我应该如何完成它。
【问题讨论】:
标签: nsnotifications xcode10 swift4.2