I\'m looking for two numbers here: the height in portrait and the height in landscape. Don\'t answer in cm or inches, but rather in pixels.
I think there are more troubles than are solved in others answers. For example, you can end up with this keyboard:
This happens when you click "hide" button on iPad keyboard on iOS 9. This keyboard has still full
size in notification info from Mike Gledhill
answer. (in UIKeyboardFrameEndUserInfoKey
height of keyboard is higher than 300).
I had to subtract y-axis origin of keyboard from device height, to come to correct value.
- (void)keyboardWillShow:(NSNotification *)notification
NSDictionary *info = [aNotification userInfo];
CGRect keyboardFrame = [info[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
keyboardFrame = [info[UIKeyboardFrameEndUserInfoKey] CGRectValue];
keyboardFrame = [self.view convertRect:keyboardFrame fromView:nil];
CGFloat yPosition = keyboardFrame.origin.y;
NSInteger height = [UIScreen mainScreen].bounds.size.height - yPosition;
}
Works for me on iOS9 with iPhones and iPads in both orientations.