的Bonjour,
我的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)];
}];
}
}
感谢您的帮助:)
答案 0 :(得分:0)
我还没有尝试过您的代码,但我坚信您所看到的内容是由已弃用的API 引起的。 Official documentation here提供详细信息,以及执行所需操作的新API viewWillTransitionToSize:withTransitionCoordinator:
还有一些关于stackoverflow的其他问题,比如讨论解决方案:willAnimateRotationToInterfaceOrientation not called on ios6/7