【问题标题】:Why is the iPad keyboard height, when in landscape mode, 1024px?为什么 iPad 键盘高度在横向模式下是 1024 像素?
【发布时间】:2012-12-21 16:05:23
【问题描述】:

我在本周早些时候遇到了这个问题,现在又遇到了。当用户处于 iPad 的横向模式时,我正在为键盘出现在屏幕上时设置我的键盘偏移量。 iPad 的尺寸为 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
}

键盘高度怎么可以是1024?这意味着键盘现在覆盖了整个屏幕。我会假设高度应该是 352,宽度应该是 1024。这是一个错误吗?

【问题讨论】:

    标签: ios ipad keyboard landscape


    【解决方案1】:

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

    UIKeyboardFrameBeginUserInfoKey

    包含 CGRect 的 NSValue 对象的键,用于标识屏幕坐标中键盘的起始帧。这些坐标不考虑由于界面方向更改而应用于窗口内容的任何旋转因素。因此,在使用它之前,您可能需要将矩形转换为窗口坐标(使用 convertRect:fromWindow: 方法)或视图坐标(使用 convertRect:fromView: 方法)。

    【讨论】:

      猜你喜欢
      • 2012-02-25
      • 1970-01-01
      • 2014-11-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-24
      • 2018-02-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多