模拟器在不同的xcode版本上产生不同的结果

时间:2015-02-10 01:57:26

标签: ios objective-c xcode keyboard

我的项目代码(cmnd + b)在 xcode 5.1.1 运行(cmnd + r)中使用模拟器iphone 5 ios 7.1生成以下内容 enter image description here

xcode 6.1.1 中运行相同的代码(cmnd + b)运行(cmnd + r)与模拟器iphone 5 ios 7.1产生以下内容 enter image description here

  • 使用模拟器iphone 5运行 xcode 6.1.1 ios 8.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;}];      
}

1 个答案:

答案 0 :(得分:1)

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

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

硬件&gt;键盘&gt;切换软件键盘

修改:这是pretty popular question