【问题标题】:Error of Value of Type 'ViewController' has no member 'keyboardDidShow(notification:)' while converting project from swift 4 to swift 5将项目从 swift 4 转换为 swift 5 时,“ViewController”类型的值错误没有成员“keyboardDidShow(notification:)”
【发布时间】:2019-08-19 12:48:20
【问题描述】:

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

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

【问题讨论】:

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

标签: ios swift


【解决方案1】:

添加方法实现

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里面

【讨论】:

    猜你喜欢
    • 2018-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多