2

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

这是我现在的定位代码

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

2 回答 2

2

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

请检查以下链接:-

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

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

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

于 2013-05-23T14:47:48.020 回答
1

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

于 2013-05-23T19:40:56.713 回答