質問

IOS6では、shouldAutorotateToInterfaceOrientationは推奨されていません。AutoRotationのためにアプリを正しく動作させて失敗しました。

このViewController私は回転したくないが、うまくいきません。

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

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
.

任意のアイデア? 事前に助けてくれてありがとう!

役に立ちましたか?

解決

はそれを考え出した。

1)サブクラスuinavigationController (階層のTop ViewControllerは向きを制御します。) Self.Window.RootViewControllerとして設定しました。

- (BOOL)shouldAutorotate
{
    return self.topViewController.shouldAutorotate;
}
- (NSUInteger)supportedInterfaceOrientations
{
    return self.topViewController.supportedInterfaceOrientations;
}
.

2)ビューコントローラを回転させたくない場合

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

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
.

3)回転できるようにしたい場合

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

-(BOOL)shouldAutorotate
{
    return YES;
}
.

BTW、あなたのニーズに応じて、他の関連方法:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
     return UIInterfaceOrientationMaskPortrait;
}
.

他のヒント

ルートコントローラとしてナビゲーションコントローラの代わりにタブバーコントローラを使用している場合は、uItabbarControllerをサブクラス化する必要があります。

も構文が異なります。私は成功して以下を使いました。その後、上書きしていたビューコントローラで上記の例を使用しました。私の場合私はメイン画面が回転しないことを望んでいましたが、私は私が自然に風景ビューを有効にしたいという映画を使ったよくある質問画面を持っていました。完全に働いた!Self.ModalViewControllerへの構文の変更を注意してください(ナビゲーションコントローラの構文を使用しようとすると、コンパイラ警告が表示されます。)これが役立つことを願っています!

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (BOOL)shouldAutorotate
{
    return self.modalViewController.shouldAutorotate;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return self.modalViewController.supportedInterfaceOrientations;
}
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top