1

iOS 6 でデバイスの回転を処理する方法がわかりません。デバイスが回転するときに、個別に変更する必要があることが 3 つあります。

  • 複数のサブ UIViewControllers または UINavigationControllers (基本的にカスタム UITabBarController) を処理する親 UIViewController があります。これは回転させたくない。
  • これらの各サブ ビュー コントローラーは、独自の設定に応じて、回転するかしないかのいずれかになります。(回転させたいものと回転させたくないものがあります)。
  • タブ バーで、各タブ アイコン (UIView) を向きに合わせて回転させます。

iOS 6 でこれを実現するにはどうすればよいでしょうか。iOS 5 ですべてが機能するようになりました。

これが私がこれまでに持っているものです:

親 UIViewController で:

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

- (BOOL)shouldAutorotate
{
    return NO;
}

- (BOOL)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

サブビューコントローラーで:

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

- (BOOL)shouldAutorotate
{
        return YES;
}

- (BOOL)supportedInterfaceOrientations
{
        return UIInterfaceOrientationMaskAll;
}
4

2 に答える 2

1

iOS6 を正しくサポートするには、もう少し作業が必要です。iOS 6 のリリース ノートでは、次のように概説されています。

https://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/_index.html

このビットは役に立つかもしれません:

互換性のために、まだ shouldAutorotateToInterfaceOrientation: メソッドを実装しているビュー コントローラーは、新しい自動回転動作を取得しません。(つまり、アプリ、アプリ デリゲート、または Info.plist ファイルを使用して、サポートされている向きを決定する方法にフォールバックしません。)代わりに、 shouldAutorotateToInterfaceOrientation: メソッドを使用して、 supportedInterfaceOrientations メソッドによって返される情報を合成します。 .

ただし、WWDC 2012 - The Evolution of View Controllers のセッション 236 もご覧ください。

于 2012-09-27T10:31:23.390 に答える
0

ナビゲーション スタックで異なる向きをサポートする場合は、最初に UINavigationController をサブクラス化し、supportedInterfaceOrientations をオーバーライドする必要があります。

- (NSUInteger)supportedInterfaceOrientations
{
    //I want to support portrait in ABCView at iPhone only.
    //and support all orientation in other views and iPad.

    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
    {
        // find specific view which you want to control.
        if ([[self.viewControllers lastObject] isKindOfClass:[ABCView class]])
        {
            return UIInterfaceOrientationMaskPortrait;
        }
    }

    //support all
    return UIInterfaceOrientationMaskAll;
}
于 2013-04-26T03:21:17.677 に答える