3

アプリの初期方向を UIInterfaceOrientationLandscapeLeft に設定しようとしています

私は得ることができません

'Initial interface orientation'[UIInterfaceOrientation]

の配列の最初の項目をオーバーライドします

'Supported interface orientations'[UISupportedInterfaceOrientations]

iPhone アプリは常に「Portrait (bottom home button)」で始まることに気付きました。配列は次のとおりです。

'Supported interface orientations'[UISupportedInterfaceOrientations]

Portrait (bottom home button)

Landscape (left home button)

Landscape (right home button)

これは予想どおりです。

概要ページの PORTRAIT HOME BOTTOM ボタンを OFF にしてから 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 テンプレート プロジェクトです... デバッグ コードを追加するだけです。

4

2 に答える 2

16

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.

于 2012-10-16T02:01:56.087 に答える