I'm trying to adjust the y origin of my sign up button to be just above the keyboard. However, this code isn't doing the trick (I don't have auto layout constraints btw)
In viewDidLoad:
// listen for keyboard height
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil)
Later I have this function:
// keyboard height adjust
func keyboardWillShow(notification: NSNotification) {
let keyboardFrame = (notification.userInfo![UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
signUpButton.frame.origin.y = keyboardFrame.origin.y - signUpButton.frame.height
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…