How to move the entire view when the keyboard pops up? (fast)

The gray box at the bottom is the text view. When I click on the text view, the keyboard will pop up from the bottom. However, the pop-up keyboard has covered the text view.

When the keyboard pops up, what function should I add to move the entire view up?

To detect when the keyboard is displayed, you can listen to NSNotificationCenter

NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: “ keyboardWillHide:", name: UIKeyboardWillHideNotification, object: nil)

That will call keyboardWillShow and keyboardWillHide. Here, you can use UITextfield to complete the required operation

< pre>func keyboardWillShow(notification: NSNotification) {
if let userInfo = notification.userInfo {
if let keyboardSize = (userInfo[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
/ /use keyboardSize.height to determine the height of the keyboard and set the height of your textfield accordingly
}
}
}

func keyboardWillHide(notification: NSNotification) {
//pull everything down again
}

The gray box at the bottom is the text view. When I click on the text view, the keyboard will pop up from the bottom. However, the pop-up keyboard has covered the text view.

When When the keyboard pops up, what function should I add to move the entire view up?

To detect when the keyboard is displayed, you can listen to NSNotificationCenter

NSNotificationCenter.defaultCenter( ).addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: “keyboardWillHide:", name: UIKeyboardWillHideNotification, object: nil)

That will call keyboardWillShow and keyboardWillHide. Here, you can use UITextfield to complete the required operation

func keyboardWillShow(notification: NSNotification) {
if let userInfo = notification.userInfo {
if let keyboardSize = (userInfo[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
//use keyboardSize.height to determine the height of the keyboard and set the height of your textfield accordingly
}
}
}

func keyboardWillHide(notification: NSNotification) {
//pull everything down again< br />}

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4254 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.