我在尝试将我的代码片段从Swift 3迁移到Swift 4.2时遇到了麻烦
这是要迁移的当前代码:
fileprivate func observeKeyboardNotifications() {
NotificationCenter.default.addObserver(self, selector: #selector(keyboardShow), name: .UIKeyboardWillShow, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardHide), name: .UIKeyboardWillHide, object: nil)
}
Run Code Online (Sandbox Code Playgroud)
这是我设法做的事情:
fileprivate func observeKeyboardNotifications() {
NotificationCenter.default.addObserver(self, selector: #selector(keyboardShow), name: NSNotification.Name.UIResponder.UIKeyboardWillShowNotification, object: nil)
}
Run Code Online (Sandbox Code Playgroud)
我仍然得到错误:
Type of expression is ambiguous without more context
Run Code Online (Sandbox Code Playgroud)
我一整天都在编码,所以我甚至无法看到这段代码出了什么问题.任何人都可以帮我解决这个问题吗?