Bonjour,iOS项目在iPhone上工作,但不在模拟器中
我的iOS项目支持风景,并在我的iPhone 4s 7.1.2上完美运行,但在模拟器中没有。
这里是一些截图:
两个截图已经采取了横向模式和模拟器似乎并没有调整板正确
这里我使用的代码改变方向。
- (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)];
}];
}
}
感谢您的帮助:)
你有没有设置断点,看看有什么价值你得到? – AdamPro13
据我所知,willAnimateRotationToInterfaceOrientation不能在模拟器上工作,因为它是由iPhone设备的加速度传感器触发的。显然,模拟器没有。 – skyline75489
你可以在iOS模拟器 - >硬件 - >向左旋转/向右旋转 – user3650409