【发布时间】:2012-12-03 12:56:47
【问题描述】:
我以编程方式创建了所有视图,IB 没有。我的视图包含导航控制器、表格视图、按钮、标签栏。现在我应该如何让我的应用程序支持 iOS 5 和 iOS 6 的所有方向。
【问题讨论】:
标签: objective-c ios xcode orientation
我以编程方式创建了所有视图,IB 没有。我的视图包含导航控制器、表格视图、按钮、标签栏。现在我应该如何让我的应用程序支持 iOS 5 和 iOS 6 的所有方向。
【问题讨论】:
标签: objective-c ios xcode orientation
把这个写在你所有的UIViewController-s:
- (NSInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
- (BOOL)shouldAutorotate {
return YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return YES;
}
【讨论】:
您是否尝试在项目目标的摘要窗格中设置支持的设备方向,如附图所示?
【讨论】:
这已在 iOS 6 中更改:
- (NSInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
【讨论】: