I've registered two observers, keyboardWillShow: and keyboardWillHide: in NSNotificationCenter
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillHide:", name: UIKeyboardWillHideNotification, object: nil)
In both these methods when I try to animate the UIView containing the UITextView, it jumps to the frame I am trying to animate to and then animates back to the original location. I tried this same animation code in the touchesBegan method to test it out and it works great there (animating to the new frame I actually set it to rather than jumping and animating back to the original location).
func keyboardWillShow(notification: NSNotification) {
if let endFrame = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.CGRectValue() {
UIView.animateWithDuration(1.0, animations: { () -> Void in
self.footerView.center = CGPointMake(self.footerView.center.x, self.footerView.center.y - endFrame.size.height)
})
}
}
I'm stumped. Does the keyboard notification affect new animations in some way?
UITextViewDelegate.- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
for example. – Larry BorsatoNSNotificationCenter
so so I can access the keyboards new frame withUIKeyboardFrameEndUserInfoKey
– sandman