我做了一些研究,但仍然找不到任何答案。场景很简单:
我有一个名为MainVC
的ViewController
我在viewDidLoad中放了2个观察者
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
我有一个UITextField
,链接了触发到MainVC的主操作,称为doneAction
每次我按下“返回”键时,它都会发布keyboardWillShowNotification
,尽管doneAction
中没有一行代码
这是UITextField
的某种错误或怪异反应吗?还是官方行为?
感谢您的帮助。