我已经在IOS 6.0中实现了示例代码并且支持方向支持它工作得很好但是如果我在ipad 1(IOS 5.1)方向上运行不同支持同样的应用程序。我知道IOS 6.0在iOS 5.1中弃用了一些方法如何解决这个问题?
答案 0 :(得分:1)
您需要在视图控制器中实现旧的旋转方法,以支持iOS 5或更低的旋转。
是的,这些方法已被弃用,但旧版本的iOS仍然需要这些方法。
答案 1 :(得分:1)
对于iOS 6+,请使用这些方法
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotate {
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
和iOS 5.0以及之前的所有使用
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
答案 2 :(得分:0)
在.m文件中使用以下代码。
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
return NO;
}
else {
return YES;
}
}
这适用于iOS 5.1,6.1.3和7.0.2。