【问题标题】:iOS: Initial interface orientation[UIInterfaceOrientation] being ignored in plistiOS:初始界面方向 [UIInterfaceOrientation] 在 plist 中被忽略
【发布时间】:2012-02-15 17:30:36
【问题描述】:

我正在尝试将我的应用的初始方向设置为 UIInterfaceOrientationLandscapeLeft

我没办法

'Initial interface orientation'[UIInterfaceOrientation]

覆盖数组中的第一项

'Supported interface orientations'[UISupportedInterfaceOrientations]

我注意到一个 iphone 应用程序总是以“人像(底部主页按钮)”开头。数组是:

'Supported interface orientations'[UISupportedInterfaceOrientations]

Portrait (bottom home button)

Landscape (left home button)

Landscape (right home button)

正如预期的那样。

如果我将“摘要”页面上的 PORTRAIT HOME BOTTOM 按钮关闭 THEN BACK ON 然后数组的顺序发生变化,Portrait(底部主页按钮)移动到底部。

Landscape (left home button)

Landscape (right home button)

Portrait (bottom home button)

当我运行该应用程序时,它现在以横向(左主页按钮)启动,因为它现在位于列表顶部。哪个好

但是

当我添加时

'Initial interface orientation'[UIInterfaceOrientation]

并将其设置为

Landscape (right home button)

它被忽略,而是使用数组中的第一项

Landscape (left home button)

我检查了 shouldAutorotateToInterfaceOrientation ,它只阻止纵向倒置

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

我还添加了调试代码

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if(interfaceOrientation == UIInterfaceOrientationPortrait){
        NSLog(@"shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait");
    }else if(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
            NSLog(@"shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortraitUpsideDown");
    }else  if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft){
            NSLog(@"shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft");
    }else if(interfaceOrientation == UIInterfaceOrientationLandscapeRight){
        NSLog(@"shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight");
    }else {
        NSLog(@"shouldAutorotateToInterfaceOrientation:UNKNOWN");
    }

    return YES;
}

我明白了

 shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
 shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
 shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
 shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
 shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
 shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft
 shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft

所以你可以看到它确实在尝试使用

'Initial interface orientation'[UIInterfaceOrientation]

并将其设置为

Landscape (right home button)

但随后它切换回数组中的第一项被使用

Landscape (left home button)

我做错了吗? 这是一个简单的 SINGLE VIEW Xcode 模板项目...只需添加调试代码。

【问题讨论】:

  • 刚刚检查了另一个项目,他们删除了数组中的所有方向,除了他们想要的方向。然后将 Initial 设置为相同的值。不能在 ipad 上工作,应该支持它们并设置 inital。

标签: iphone ios uiinterfaceorientation device-orientation


【解决方案1】:

尽管有文档,UIInterfaceOrientation 仍被忽略。仅使用UISupportedInterfaceOrientations。要指定您喜欢启动哪个,请将其设为第一个UISupportedInterfaceOrientations 中列出的。

然后由您的个人视图控制器来排除他们拒绝采用的任何方向。

【讨论】:

  • 这也为我修好了。
【解决方案2】:

初始界面方向对我不起作用。我只是更改了支持的界面方向的顺序,它起作用了。

【讨论】:

  • 绝对正确!另外:这里的项目顺序很重要!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-05
  • 1970-01-01
  • 1970-01-01
  • 2015-06-19
相关资源
最近更新 更多