iOS:初始界面方向 [UIInterfaceOrientation] 在 plist 中被忽略

发布于 2025-01-06 02:36:18 字数 3280 浏览 0 评论 0原文

我正在尝试将我的应用程序的初始方向设置为 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 按钮关闭然后再打开 然后数组的顺序发生变化,纵向(底部主页按钮)移动到底部。

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 模板项目...只需添加调试代码。

I'm trying to set the initial orientation for my app to be
UIInterfaceOrientationLandscapeLeft

I cant get

'Initial interface orientation'[UIInterfaceOrientation]

to override the first item in array of

'Supported interface orientations'[UISupportedInterfaceOrientations]

I noticed an iphone app always starts with 'Portrait (bottom home button)'.and the array is:

'Supported interface orientations'[UISupportedInterfaceOrientations]

Portrait (bottom home button)

Landscape (left home button)

Landscape (right home button)

Which is as expected.

If I turn PORTRAIT HOME BOTTOM button on Summary page OFF THEN BACK ON
then the order of the array changes and Portrait (bottom home button) moves to the bottom.

Landscape (left home button)

Landscape (right home button)

Portrait (bottom home button)

and when I run the app it now starts in Landscape (left home button) as this is now top of the list. Which is fine

BUT

when I add

'Initial interface orientation'[UIInterfaceOrientation]

and set it to

Landscape (right home button)

Its ignored and the first item in the array is used instead

Landscape (left home button)

I checked shouldAutorotateToInterfaceOrientation and it only blocks Portrait upside down

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

I also added debug code

- (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;
}

and I get

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

so you can see it does try an use

'Initial interface orientation'[UIInterfaceOrientation]

and set it to

Landscape (right home button)

but then it switches back to the first item in the array is used instead

Landscape (left home button)

am I doing something wrong?
This is a simple SINGLE VIEW Xcode Template project... just add the debug code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

染年凉城似染瑾 2025-01-13 02:36:18

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

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

Despite the documentation, UIInterfaceOrientation is ignored. Use only UISupportedInterfaceOrientations. To specify which one you prefer to launch into, make it the first one listed in UISupportedInterfaceOrientations.

It is then up to your individual view controllers to rule out any orientations they refuse to adopt.

后eg是否自 2025-01-13 02:36:18

初始界面方向对我来说不起作用。我刚刚更改了支持的界面方向的顺序并且它起作用了。 输入图片此处描述

Initial Interface Orientation did not worked for me. I just changed the sequence in supported interface orientation and it worked. enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文