0

ストーリーボードを使用しています。回転させたいすべてのView Controllerに、このメソッドを次のように含めました。

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

iOS 6 では、ストーリー ボードの横向きと縦向きの適切なビューにうまく回転します。

iOS 5 では、親ビュー コントローラーは回転しますが、モーダルは画面上にある間は回転しません。画面上にある前にのみ回転し、その間は回転しません。したがって、ユーザーが方向を変更しても、方向は変わりません。親は画面上で変更されますが、モーダルは親が持っていた向きになりますが、画面上では変更されません。画面上でモーダル ビューが回転する iOS 6 のようにモーダル ビューを動作させるにはどうすればよいですか。モーダル ビューは、ストーリーボードを介して作成されました。

編集*

モーダルにポップオーバーすると、モーダルが回転しません。どうすればこれを修正できますか?

4

1 に答える 1

1

回転は、iOS5とiOS6で異なる方法で処理されます。以下のコードを使用して、両方のバージョンをサポートします。

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

// iOS6
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

- (BOOL)shouldAutorotate
{
    return YES;
}

shouldAutorotateToInterfaceOrientation:iOS6では非推奨です。ここで読むことができます: http: //developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instm/UIViewController/shouldAutorotateToInterfaceOrientation

于 2013-01-18T20:22:37.940 に答える