当 ViewController 消失时删除键盘通知 [英] Remove keyboard notification when ViewController disappears
本文介绍了当 ViewController 消失时删除键盘通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何移除键盘通知?
我让观察者在键盘上打开和关闭.
I put observer on keyboard open and close.
我根据键盘是打开还是关闭来更改视图大小.
I change the view size depend on keyboard is open or close.
推荐答案
试试这个删除键盘打开显示观察者,
Try this to remove keyboard open show observers,
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillShow, object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillHide, object: nil)
您应该根据您的要求在 deinit
或 viewDidDisappear
中删除观察者.
you should remove observers either in deinit
Or viewDidDisappear
as per your requirement.
这篇关于当 ViewController 消失时删除键盘通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文