I have a UIView
with a UITextField
placed at the bottom of the screen which will move up when a keyboard appears.
I have been following the below method prior to iOS 8 and seems to work perfectly.
// When Keyboard appears
- (void)keyboardWillShow:(NSNotification *)notification {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:[notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
[UIView setAnimationCurve:[notification.userInfo[UIKeyboardAnimationCurveUserInfoKey]integerValue]];
[UIView setAnimationBeginsFromCurrentState:YES];
// Frame Update
CGRect frame = self.bottomView.frame;
frame.origin.y = self.view.frame.size.height - 266.0f;
self.bottomView.frame = frame;
[UIView commitAnimations];
}
// When keyboard disappears
- (void) keyboardHides : (NSNotification *) notification {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:[notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
[UIView setAnimationCurve:[notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue]];
[UIView setAnimationBeginsFromCurrentState:YES];
// Frame update
CGRect frame = self.bottomView.frame;
frame.origin.y = self.view.frame.size.height - self.bottomView.frame.size.height;
self.bottomView.frame = frame;
[UIView commitAnimations];
}
But the above code doesn't seem to work in iOS 8
as the keyboard blocks the UIView behind it.
After a little research, I found out an almost-similar answer. But here the whole UIView
was being pushed up, and what I would like to achieve was just to move the bottom UIView
.