0
When the keyboard is displayed or inhibited, you can listen to notifications to process them. In your view controller, sign up to listen to these events as follows:
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow), name: .UIKeyboardDidShow , object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidHide), name: .UIKeyboardDidHide , object: nil)
}
You should also create the functions you are reporting on selector
:
@objc private func keyboardDidShow() {
// Processe aqui para quando o teclado terminar de ser *exibido*
}
@objc private func keyboardDidHide() {
// Processe aqui para quando o teclado terminar de ser *inibido*
}
There are four such events for the keyboard:
.UIKeyboardWillShow
;.UIKeyboardDidShow
;.UIKeyboardWillHide
;.UIKeyboardDidHide
.
You can sign any of them to listen to keyboard related changes.
A longer list of events related to your application can be found here.