小编CVa*_*Var的帖子

NotificationCenter将swift 3迁移到swift 4.2问题

我在尝试将我的代码片段从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)

我一整天都在编码,所以我甚至无法看到这段代码出了什么问题.任何人都可以帮我解决这个问题吗?

migration syntax notificationcenter swift

5
推荐指数
1
解决办法
5203
查看次数

标签 统计

migration ×1

notificationcenter ×1

swift ×1

syntax ×1