iOS项目适用于iPhone但不适用于模拟器

时间:2015-01-16 23:18:31

标签: ios objective-c iphone xcode ios-simulator

的Bonjour,

我的iOS项目支持横向并在我的iPhone 4s 7.1.2上完美运行,但不在模拟器中运行。

这里有一些截图:

iPhone Landscape

Simulator Landscape

这两个截图都是在横向模式下拍摄的,模拟器似乎没有正确调整电路板的大小

这里是我用来改变方向的代码。

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight){
    [UIView animateWithDuration:duration animations:^{

        [[UIApplication sharedApplication] setStatusBarHidden:YES];

        int width = [[UIScreen mainScreen] bounds].size.width - [[UIApplication sharedApplication] statusBarFrame].size.width - 10;
        int height = width;

        int x = 5;
        int y = ([[UIScreen mainScreen] bounds].size.width / 2) - (width / 2);

        [board setFrame:CGRectMake(x, y, width, height)];
    }];
}
else {
    [UIView animateWithDuration:duration animations:^{

        [[UIApplication sharedApplication] setStatusBarHidden:NO];
        [board setFrame:CGRectMake(0, [UIApplication sharedApplication].statusBarFrame.size.height, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.width)];
    }];
}

}

感谢您的帮助:)

1 个答案:

答案 0 :(得分:0)

我还没有尝试过您的代码,但我坚信您所看到的内容是由已弃用的API 引起的。 Official documentation here提供详细信息,以及执行所需操作的新API viewWillTransitionToSize:withTransitionCoordinator:

还有一些关于stackoverflow的其他问题,比如讨论解决方案:willAnimateRotationToInterfaceOrientation not called on ios6/7