Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From the <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html#//apple_ref/doc/uid/TP40006817-CH3-SW27" rel="noreferrer">documentation</a> for <code>UIKeyboardBoundsUserInfoKey</code>:</p> <blockquote> <p><em>The key for an NSValue object containing a CGRect that identifies the bounds rectangle of the keyboard in window coordinates. This value is sufficient for obtaining the size of the keyboard. If you want to get the origin of the keyboard on the screen (before or after animation) use the values obtained from the user info dictionary through the UIKeyboardCenterBeginUserInfoKey or UIKeyboardCenterEndUserInfoKey constants. <strong>Use the UIKeyboardFrameBeginUserInfoKey or UIKeyboardFrameEndUserInfoKey key instead.</em></strong></p> </blockquote> <p>Apple recommends implementing a convenience routine such as this (which could be implemented as a category addition to <code>UIScreen</code>):</p> <pre><code>+ (CGRect) convertRect:(CGRect)rect toView:(UIView *)view { UIWindow *window = [view isKindOfClass:[UIWindow class]] ? (UIWindow *) view : [view window]; return [view convertRect:[window convertRect:rect fromWindow:nil] fromView:nil]; } </code></pre> <p>to recover window-adjusted keyboard frame size properties.</p> <p>I took a different approach, which involves checking the device orientation:</p> <pre><code>CGRect _keyboardEndFrame; [[notification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] getValue:&amp;_keyboardEndFrame]; CGFloat _keyboardHeight = ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown) ? _keyboardEndFrame.size.height : _keyboardEndFrame.size.width; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload