iOS:在plist中忽略初始界面方向[UIInterfaceOrientation] [英] iOS: Initial interface orientation[UIInterfaceOrientation] being ignored in plist

查看:84
本文介绍了iOS:在plist中忽略初始界面方向[UIInterfaceOrientation]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我无法获得

'Initial interface orientation'[UIInterfaceOrientation]

覆盖数组中的第一项

'Supported interface orientations'[UISupportedInterfaceOrientations]

我注意到一个iphone应用总是以'Portrait(底部主页按钮)'开头。数组是:

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)

这是预期的。

如果我在摘要页面上关闭PORTRAIT HOME BOTTOM按钮OFF THEN BACK ON
然后数组的顺序改变,而Portrait(底部主页按钮)移动到底部。

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

当我添加

'Initial interface orientation'[UIInterfaceOrientation]

并设置它到

Landscape (right home button)

它被忽略了,而数组中的第一项用来代替

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

Landscape (left home button)

我检查了shouldAutorotateToInterfaceOrientation它只会阻止人像颠倒

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

我还添加了调试代码

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

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

so you can see it does try an use

'Initial interface orientation'[UIInterfaceOrientation]

并将其设置为

Landscape (right home button)

然后它切换回数组中的第一项是改为使用

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

Landscape (left home button)

我做错了什么?
这是一个简单的单一视图Xcode模板项目...只需添加调试代码。

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

推荐答案

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

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.

这篇关于iOS:在plist中忽略初始界面方向[UIInterfaceOrientation]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆