I am making a custom IOS keyboard. I was wondering if there is any method that is called whenever the user selects the keyboard, thus making it pop up on screen. This is because I want to run some code whenever the keyboard pops up.
No method is called. A notification is posted though. You can read more about it in the Managing the Keyboard section of the Text Programming Guide for iOS .
The notification: UIKeyboardDidShowNotification
is called. You can create an observer to this method that triggers a function for both actions like this:
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardDidShow:"), name:UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardDidHide:"), name:UIKeyboardWillHideNotification, object: nil)
func keyboardDidShow(notification: NSNotification) {
print("Keyboard shown")
}
func keyboardDidHide(notification: NSNotification) {
print("Keyboard hidden")
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.