【问题标题】:simulator produce different result on different xcode versions [duplicate]模拟器在不同的xcode版本上产生不同的结果[重复]
【发布时间】:2023-04-04 13:56:01
【问题描述】:

我在 xcode 5.1.1 中构建的项目代码 (cmnd + b) 使用模拟器 iphone 5 ios 7.1 运行 (cmnd + r) 产生以下结果

xcode 6.1.1 中构建的相同代码 (cmnd + b) 使用模拟器 iphone 5 ios 7.1 运行 (cmnd + r) 产生以下结果

  • 使用模拟器 iphone 5 ios 8.1xcode 6.1.1 中运行看起来不错(就像 xcode 5.1.1 中的第一张图片)

有什么想法吗?

这是显示键盘的代码:

- (void)showKeyboard:(NSNotification*)notification
{
    NSValue *keyboardEndFrameValue = [[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardEndFrame = [keyboardEndFrameValue CGRectValue];

    NSNumber *animationDurationNumber = [[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey];
    NSTimeInterval animationDuration = [animationDurationNumber doubleValue];

    NSNumber *animationCurveNumber = [[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey];
    UIViewAnimationCurve animationCurve = [animationCurveNumber intValue];

    UIViewAnimationOptions animationOptions = animationCurve << 16;

    int searchBarYPadding = 60;
    if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0f)
    {
        searchBarYPadding = 42;
    }

    [UIView animateWithDuration:animationDuration
                          delay:0.0
                        options:animationOptions
                     animations:^{
                         CGRect textFieldFrame = self.addressSearchBar.frame;
                         textFieldFrame.origin.y = keyboardEndFrame.origin.y - searchBarYPadding;
                         self.addressSearchBar.frame = textFieldFrame;
                     }
                     completion:^(BOOL finished) {isKeyboardDisplayed = YES;}];      
}

【问题讨论】:

    标签: ios objective-c xcode keyboard


    【解决方案1】:

    尝试在模拟器中按⌘-K 来切换软件键盘。

    您也可以在菜单中找到它:

    硬件 > 键盘 > 切换软件键盘

    编辑:这是pretty popular question

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-05
      • 1970-01-01
      • 2014-12-29
      • 1970-01-01
      • 2019-07-08
      • 2018-03-27
      • 2020-09-17
      相关资源
      最近更新 更多