Why is the iPad keyboard height, when in landscape mode, 1024px?
Asked Answered
S

1

5

I ran into this issue earlier in the week and again just now. I'm in the process of setting my keyboard offset for when the keyboard appears on the screen when the user is in landscape mode of an iPad. iPads have a dimension of 1024 x 768.

- (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: 1024.000000 Width: 352.000000
}

How is it that the height of the keyboard can be 1024? This would mean that the keyboard is now covering the entire screen. I would assume that the height should be 352, and the width should be 1024. Is this a bug?

Solidary answered 21/12, 2012 at 16:5 Comment(0)
P
10

From http://developer.apple.com/library/ios/documentation/uikit/reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html#//apple_ref/doc/uid/TP40006817-CH3-SW27

UIKeyboardFrameBeginUserInfoKey

The key for an NSValue object containing a CGRect that identifies the start frame of the keyboard in screen coordinates. These coordinates do not take into account any rotation factors applied to the window’s contents as a result of interface orientation changes. Thus, you may need to convert the rectangle to window coordinates (using the convertRect:fromWindow: method) or to view coordinates (using the convertRect:fromView: method) before using it.

Polyphonic answered 21/12, 2012 at 16:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.