I am trying to run a function when the keyboard shows and disappears and have the following code:
let notificationCenter = NotificationCenter.default
notific
set keyboard notification observer in
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardNotification(notification:)), name: NSNotification.Name.UIKeyboardDidShow, object: nil)
}
and in your function handle it
func keyboardNotification(notification: NSNotification) {
print("keyboard displayed!!")
}
hope this will help you.