1

私は実装しました

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}

私のすべてのコントローラーで。info.plist に 4 の向きがありますが、アプリは回転したくありません。回転するのはトップバーだけです。私のテーブルビューは回転しません...しかし、テーブルビューの背後にあるはずのように回転しているのを見ることができますが、元のテーブルビュー(回転していないもの)がそのすぐ上にあるため、アクセスできません画面の 95%。

見た目についてはこんな感じ

あなたが私に与えることができるあらゆるサポートに感謝します!

4

3 に答える 3

1

ViewController.mクラスで、代わりに実行したいのは、以下に示すように、viewDidDisapearメソッドの下に表示されているコードをコピーして貼り付けることです。

/*
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}
*/

 // Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait || UIInterfaceOrientationLandscapeLeft || UIInterfaceOrientationLandscapeRight);
}

お役に立てれば!

于 2012-08-31T16:09:06.283 に答える
1

ビューが自動的に回転しない同様の問題があります。解決策はありませんが、回避策があります。ビュー コントローラーの willRotateToInterfaceOrientation で、ビューを明示的に回転します。

    switch (toInterfaceOrientation) {
        case UIInterfaceOrientationLandscapeLeft:
            self.view.transform = CGAffineTransformMakeRotation(M_PI * 0.5);
            break;
        case UIInterfaceOrientationLandscapeRight:
            self.view.transform = CGAffineTransformMakeRotation(M_PI * -0.5);
            break;
        case UIInterfaceOrientationPortrait:
            self.view.transform = CGAffineTransformMakeRotation(0);
            break;
        case UIInterfaceOrientationPortraitUpsideDown:
            self.view.transform = CGAffineTransformMakeRotation(M_PI * 1);
            break;
        default:
            break;
    }

明示的な CGAffineTransformMakeRotation 呼び出しなしでビューが自動的に回転するはずなので、これを回避策と呼んでいます。私の場合、このように回転する必要があるランドスケープ用の別のビューをインスタンス化しています。別のビューが自動的に回転する他のプロジェクトがあります。この場合、なぜそれをしないのかわかりません。

于 2012-09-03T09:26:15.717 に答える
0

これはあなたに役立つかもしれません

     if(interfaceOrientation==UIInterfaceOrientationLandscapeLeft||interfaceOrientation==   UIInterfaceOrientationLandscapeRight||interfaceOrientation==UIInterfaceOrientationPortrait||interfaceOrientation ==UIInterfaceOrientationPortraitUpsideDown)
   {

           return YES;
   }
于 2012-08-31T13:52:43.583 に答える