Testing my app on iOS 11 beta 7 - it seems like the keyboard doesn't push up the content if my UIViewController.
The code looks like this (working since iOS7):
- (void)handleNotification:(NSNotification*)notification {
if (notification.name == UIKeyboardWillShowNotification) {
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
nextButtonALBottomDistance.constant = keyboardSize.height + initialPhoneBottomDistance;
codeBottomViewALBottomDistance.constant = keyboardSize.height + initialCodeBottomDistance;
double animationDuration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:animationDuration animations:^{
[self.view layoutIfNeeded];
}];
}
else if (notification.name == UIKeyboardWillHideNotification) {
nextButtonALBottomDistance.constant = initialPhoneBottomDistance;
codeBottomViewALBottomDistance.constant = initialCodeBottomDistance;
double animationDuration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:animationDuration animations:^{
[self.view layoutIfNeeded];
}];
}
}
Interesting enough - when I press the home button (minimizing the app) and reopening it (without killing it) - the layout is fixed.
It seems like an iOS 11 beta bug, but I couldn't find any reference to it so far.
Happy to know if someone else is having this issue.
Use UIKeyboardFrameEndUserInfoKey because that key is for the NSValue object containing a CGRect that identifies an end frame of the keyboard in screen coordinates. Do not use UIKeyboardFrameBeginUserInfoKey.