3

デバイスの回転に問題があります。会社のスプラッシュ スクリーンを表示する 1 つのビューを除いて、残りのすべてのアプリ ビューを縦表示にロックしたいと考えています。プロジェクト設定でサポートされている向きは、Portrait と LandscapeLeft です。「Company Splash」では問題なく動作し、デバイスをどのように回転させても、ビューの回転は LandscapeLeft にロックされます。他のすべてのビューでは、デバイスを左に回転させると、縦表示のままではなく、ビューが変更されます。メソッドは発砲さえしていませんか?プロジェクトでサポートされている方向からランドスケープを削除すると、「会社のスプラッシュ」ビューが台無しになります。shouldAutorotatereturn をに変更してみましNOたが、解決しませんでした。ここに投稿された提案を通して自分の道を歩もうとしました、しかしそれは助けにはなりませんでした。次のコードを AppDelegate.m に入れると、すべてが縦向きモードにロックされ、アクセス時に「Company Splash」がクラッシュします。

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

1 つの画面を除いてデバイスをどのように回転させても、ビューをポートレート モードにロックするにはどうすればよいですか?

** 「カンパニー スプラッシュ」ビューからのメソッド。繰り返しますが、想定どおりに動作します。

-(NSInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft;
}

** 他のすべてのビューのメソッド。必要に応じてポートレートから回転します。

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // IOS5 Only returning that it should rotate to potrait
    return (interfaceOrientation == UIDeviceOrientationPortrait);
}

-(BOOL)shouldAutorotate
{
    // forcing the rotate IOS6 Only
    return YES;
}

-(NSInteger)supportedInterfaceOrientations
{
    // return number or enum IOS6 Only
    return UIInterfaceOrientationMaskPortrait;
}

UITabBarController がルートコントローラーであり、私はそれから離れた ViewController にいるのではないかと思いましたか? メソッドは発砲さえしていませんか?

4

3 に答える 3

6

次のように、回転させたいビューの viewDidLoad メソッドにオブザーバーを追加します。

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]
 addObserver:self selector:@selector(orientationChanged:)
 name:UIDeviceOrientationDidChangeNotification
 object:[UIDevice currentDevice]];

次に、次のように、 orientationChangedメソッド内のランドスケープ ビューに従ってビューを設定します。

- (void) orientationChanged:(NSNotification *)note{
UIDevice * device = [UIDevice currentDevice];
switch(device.orientation)
{
    case UIDeviceOrientationPortrait:

        break;
    case UIDeviceOrientationPortraitUpsideDown:

        break;
    case UIDeviceOrientationLandscapeLeft:

        break;
    case UIDeviceOrientationLandscapeRight:

        break;

    default:
        break;
  };
}
于 2013-02-27T13:08:50.357 に答える
2

このメソッドを、特定の向きでロックしたいView Controllerに叩き込みます。

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

必要な向きに変更するだけです(上記では横向きにロックされています)

于 2014-09-04T20:48:26.180 に答える
0

たぶん、すべての向きを許可し、会社のスプラッシュを除く各クラスで縦向きをロックする必要があります

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (interfaceOrientation == UIInterfaceOrientationPortrait) {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    } else {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }
}
于 2013-02-27T11:32:37.683 に答える