1

現在、私はすべてのビューにこのコードを持っていますが、1つを除くすべてのランドスケープには入りたくありません:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// You do not need this method if you are not supporting earlier iOS Versions
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

-(NSUInteger)supportedInterfaceOrientations
{
if (self.selectedViewController)
    return [self.selectedViewController supportedInterfaceOrientations];

return UIInterfaceOrientationMaskPortrait;
}

-(BOOL)shouldAutorotate
{
return YES;
}

これは私のタブバーコントローラーのコードです:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// You do not need this method if you are not supporting earlier iOS Versions
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

-(NSUInteger)supportedInterfaceOrientations
{
if (self.selectedViewController)
    return [self.selectedViewController supportedInterfaceOrientations];

return UIInterfaceOrientationMaskPortrait;
}

-(BOOL)shouldAutorotate
{
return YES;
}

そして最後に、横向きにしたいビューコントローラーのコード(ビデオがあるため):

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

- (BOOL)shouldAutorotate
{
return YES;
}

- (NSInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}

ビューはすべて私が望むように回転しています。唯一の問題は、ビデオが回転しているビューコントローラーが回転し、別のビューをクリックしてそのビューが横向きのままになることです。私が望むのは、このビューを縦向きにまっすぐ回転させることですユーザーがデバイスを縦向きに回転させる必要はありません。必要なコードを知っている人はいますか?

4

1 に答える 1

0

これは、エレガントに解決するのが難しい場合があります。オリエンテーションを強制すると、ヒューマン インターフェイス ルールのルールに違反するか、過去にはプライベート API を呼び出すだけで済みました。

過去にうまくいった別のアプローチを試すことをお勧めします。ユーザーが回転すると、ビデオを表示する 1 つのビューコントローラーを回転させることができますが、その時点で、ユーザーが移動できる方法をすべて削除し、デバイスを回転させて縦向きに戻すと、それらのナビゲーション コントロールが返されます。私にとっては、縦向きに戻るまでナビゲーションバーを非表示にするだけでした。移動する前に携帯電話を縦向きに戻さなければならないことがユーザーにとって非常に明確であり、魔法のように別の方向である別の場所をナビゲートしても驚かないため、私はこれが好きです.

于 2013-02-13T23:57:59.687 に答える