On iPad, after subscribing to UIKeyboardDidShowNotification
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
NSLog(@"%@", NSStringFromCGSize(kbSize));
prints {352, 1024}
Isn't this wrong? Not only is height of keyboard so large, how can height be larger than width? Or am i missing something?
I bet the dimensions are reported in a static orientation (the 'window' orientation never actually changes), so I suggest translating that to your view of interest. My normal trick is to convert it to the coordinate space of the window's rootViewController's view:
CGRect rawKeyboardRect = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGRect properlyRotatedCoords = [self.view.window convertRect:rawKeyboardRect toView:self.view.window.rootViewController.view];
Or a more appropriate view if you have one available. The key is that any coordinates reported in the window's coordinate space are not rotated, even if the window's rootVC's view is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With