【发布时间】:2019-04-04 14:01:44
【问题描述】:
当键盘挡住他们的视线时,我有这个功能可以向上移动某些文本字段 - 我相信你们都知道这一点:
override func viewDidLoad() {
super.viewDidLoad()
let center: NotificationCenter = NotificationCenter.default
center.addObserver(self, selector: #selector(keyboardDidShow(notification:)), name: NSNotification.Name?.UIKeyboardDidShow, object: nil)
center.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: NSNotification.Name?.UIKeyboardWillHide, object: nil)
}
但是当我最近更新到 swift 4.2 时,这些停止工作,并且提出了以下建议:
将“UIKeyboardDidShow”替换为“UIResponder.keyboardDidShowNotification”&
将“UIKeyboardWillHide”替换为“UIResponder.keyboardWillHideNotification”
但是当我按下“修复”时,我得到了错误(x2):
类型“NSNotification.Name”没有成员“UIResponder”
这对我来说似乎是一个错误?那个xCode不能接受它自己的改变??有人遇到过这种情况并知道该怎么做吗?
谢谢!
【问题讨论】:
标签: ios swift keyboard uitextfield xcode4.2