ios - 将项目从 swift 4 转换为 swift 5 时,“ViewController”类型的值错误没有成员“keyboardDidShow(notification:)”
问题描述
将项目从Swift 4转换为Swift 5时,类型值错误ViewController
没有成员。下面是现在给出错误的代码keyboardDidShow(notification:)
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里面
推荐阅读
- c# - Threadpool 不同的返回结果?
- rxjs - 如何使用减少/扫描(在 NGRX/NGXS 中)从可观察的数组中制表/汇总总值
- python - Pandas:执行多个复杂聚合的惯用方式?
- java - 如何使用脚本通过 Java API 更新 elsaticsearch 文档中的一个文件?
- python - 从特定目录读取多个图像,预先设置并使用 python 和 opencv 将它们保存到另一个目录
- java - 如何在 Azure Devops 的 Maven@3 任务中将 maven 选项传递给 JaCoCo 工具
- linux - 如何将汇编代码修补到exe文件的末尾
- c# - 如何在 Xamarin.forms C# 中检查长时间下载的数据
- python - 使用 stringvar 的 Python 标签
- c# - 为什么我的asp页面执行缓存代码