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.
On the iPad, the keyboard size can also depend on the language (e.g. the japanese keyboard is taller). Another reason to query it programmatically.
The portrait height is 264 while the landscape height is 352.
I know this is a late answer, but I just came across this question myself.
Heights are: PORTRAIT = 264 LANDSCAPE = 352
- (void) keyboardWasShown:(NSNotification *)nsNotification {
NSDictionary *userInfo = [nsNotification userInfo];
CGSize kbSize = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
NSLog(@"Height: %f Width: %f", kbSize.height, kbSize.width);
// Portrait: Height: 264.000000 Width: 768.000000
// Landscape: Height: 352.000000 Width: 1024.000000
}
I don't know what it is, but you could figure it out easily enough.
Surf on your iPad to a page with this...
var totalHeight = window.innerHeight;
document.getElementById('what-is-my-height').onclick = function() {
alert(totalHeight - window.innerHeight);
};
<button id="what-is-my-height">Bring up keyboard, then push me</button>
Click the button (after you have brought up the on screen keyboard), and it should tell you the height. Repeat for the other orientation.
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.