Ios 类型为'的值错误;ViewController';没有成员';键盘显示(通知:)&x27;将项目从swift 4转换为swift 5时

Ios 类型为'的值错误;ViewController';没有成员';键盘显示(通知:)&x27;将项目从swift 4转换为swift 5时,ios,swift,Ios,Swift,将项目从Swift 4转换为Swift 5时,类型ViewController的值错误没有成员keyboardDidShow(通知:)。下面是现在给出错误的代码 NotificationCenter.default.addObserver(self, selector:#selector(self.keyboardDidShow(notification:)), name: UIResponder.keyboardDidShowNotification, object: nil) 添加方法实

将项目从Swift 4转换为Swift 5时,类型
ViewController
的值错误没有成员
keyboardDidShow(通知:)
。下面是现在给出错误的代码

 NotificationCenter.default.addObserver(self, selector:#selector(self.keyboardDidShow(notification:)), name: UIResponder.keyboardDidShowNotification, object: nil)

添加方法实现

class ViewController:UIViewController {
    override func viewDidLoad() {
      super.viewDidLoad()
      NotificationCenter.default.addObserver(self, selector:#selector(self.keyboardDidShow(notification:)), name: UIResponder.keyboardDidShowNotification, object: nil)
   }
   @objc func keyboardDidShow(notification:NSNotification) {}
}

在vc中添加方法实现

class ViewController:UIViewController {
    override func viewDidLoad() {
      super.viewDidLoad()
      NotificationCenter.default.addObserver(self, selector:#selector(self.keyboardDidShow(notification:)), name: UIResponder.keyboardDidShowNotification, object: nil)
   }
   @objc func keyboardDidShow(notification:NSNotification) {}
}

在vc内部

在视图控制器中添加keyboardDidShow()。更新问题时出错!在视图控制器中添加keyboardDidShow()。更新有错误的问题!