在应用开始时强制横向模式,但允许稍后更改方向

我计划允许用户旋转设备但是在启动期间,我希望应用程序从横向模式开始。 我可以知道我该怎么办?

这是我现在的代码方向

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } else { return YES; } } 

您需要检查状态栏的方向。

请检查以下链接: –

强制iOS应用以横向模式启动

模态视图控制器强制iOS 6中的横向方向

Objective-C中iOS 6上的强制横向方向

在项目设置/目标设置(左侧导航栏顶部的蓝色图标,xcode中)中,有用于指定方向的设置。 您将看到4个图像,每个图像都可以选择或取消选择。 只选择您最初想要的应用程序,然后您可以使用shouldAutorotatesupportedInterfaceOrientation方法来允许或禁止某些方向。
支持的接口方向也在plist中指定。 确保将应用程序的初始方向保留在plist文件中supoortedInterfaceOrientations列表的顶部。