【发布时间】:2018-09-17 13:02:53
【问题描述】:
这是我添加观察者的函数
func subscribeToKeyboardNotifications() {
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: .UIKeyboardWillShow, object: nil)
}
但是.UIKeyboardWillShow 给了我一个错误
'UIKeyboardWillShow' 已重命名为 'UIResponder.keyboardWillShowNotification'
将“UIKeyboardWillShow”替换为 'UIResponder.keyboardWillShowNotification'
但是当我替换它时
func subscribeToKeyboardNotifications() {
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: .UIResponder.keyboardWillShowNotification, object: nil)
}
我收到这个错误
没有更多上下文的表达类型是模棱两可的
【问题讨论】:
-
您需要删除
.之前的UIResponder。 stackoverflow.com/questions/52316676/… -
而且你需要导入 UIKit 模块而不是 Foundation