Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad keyboard dimensions

I have found the iPhone's keyboard bounds in the apple documentation, but I can't find the iPad's keyboard bounds. Could you please help me?

like image 578
Infinite Possibilities Avatar asked Apr 30 '10 08:04

Infinite Possibilities


People also ask

What size is the iPad Magic Keyboard?

The iPad Pro Magic Keyboard comes in two sizes: 11-inch and 12.9-inch. The 11-inch size is compatible with the 11-inch iPad Pro as well as the iPad Air 4.

What size are Apple keyboards?

What are the dimensions of the Apple Magic Keyboard? The Apple Magic Keyboard has a width of 10.98” | 27.9 cm, depth of 4.52” | 11.49 cm, and slightly angled height that grows from . 16” | 4.1 mm to . 43” | 10.9 mm.

How thick is the iPad Pro with Magic Keyboard?

The 2021 model is 6.4mm (0.25 inches) thick, while the 2020 version is 5.9mm (0.23 inches) in depth. This half-millimeter difference is a sliver of material, which for the vast majority of cases and other accessories you can purchase, should not matter at all.


2 Answers

The entire answer in code looks like this. First you need to register for the notifications:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];

and there are more here. Note that you'll need to get rid of them, too (use removeObserver).

Then you need a method that gets the notification to get the size. Note that the size is, at first, not rotated (since the UIWindow doesn't rotate. Its contents do).

- (void) keyboardDidShow:(NSNotification*)notification {
        CGRect keyboardFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
        NSLog(@"keyboard frame raw %@", NSStringFromCGRect(keyboardFrame));

        UIWindow *window = [[[UIApplication sharedApplication] windows]objectAtIndex:0];
        UIView *mainSubviewOfWindow = window.rootViewController.view;
        CGRect keyboardFrameConverted = [mainSubviewOfWindow convertRect:keyboardFrame fromView:window];
        NSLog(@"keyboard frame converted %@", NSStringFromCGRect(keyboardFrameConverted));
}

Obviously, if you have a reference to your mainSubviewOfWindow by some other means, use it.

like image 56
Dan Rosenstark Avatar answered Nov 12 '22 09:11

Dan Rosenstark


For iPhone in portrait 216 pixels, landscape 162 pixels, for iPad in portrait it's 264 pixels and in landscape 352 pixels. This is valid for US keyboard in 2010.

These sizes can be different for other languages, and might change for US as well.

like image 20
Peter Robert Avatar answered Nov 12 '22 09:11

Peter Robert