下面的代码在 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.
...但我不知道我应该如何完成它。