4

iOS 5 および iOS 6 を対象としたアプリを作成しましたが、何らかの理由で、iOS 6 を搭載したデバイスで使用した場合にのみ回転し、iPhone または iPad で回転し、iOS 5 を使用したデバイスでは回転しません。普遍的です。この問題を解決するのを手伝ってください! ありがとう

4

5 に答える 5

8
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return ((toInterfaceOrientation == UIInterfaceOrientationPortrait) || (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown));
}

- (NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}

すべての uiviewcontroller サブクラスでこれら 2 つのメソッドをオーバーライドします。これは iOS 6 以前で機能します。

于 2013-03-06T06:22:20.457 に答える
5

iOS5とiOS6は、異なる方向と回転のデリゲートを呼び出します。iOS 5では、以下を実装します。

shouldAutorotateToInterfaceOrientation:、これはiOS6で非推奨になりました。

したがって、iOS 6では、ルートビューコントローラーを設定し、以下を実装していることを確認してください。

shouldAutorotate:、supportedInterfaceOrientationsおよびsupportedInterfaceOrientationsForWindow:

于 2012-10-27T18:08:30.290 に答える
0

同様の問題がありました。この質問の答えを確認できます:

iOS6 で回転の動作が異なる

要約すると、iOS 5 と iOS 6 で自動回転を完全に機能させ、PortraitUpsideDown の向きも処理するには、カスタムの UINavigationController を実装しself.window.rootViewControllerて、アプリのデリゲートdidFinishLaunchingWithOptionsメソッドに割り当てる必要がありました。

于 2012-10-28T02:41:04.333 に答える
0

shouldAutorotateToInterfaceOrientation は ios6 で廃止されました。

したがって、両方の OS バージョンでアプリを実行する場合は、次のように shouldAutorotateToInterfaceOrientation も追加します

//for ios6
 - (BOOL)shouldAutorotate {

        UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];

        if (orientation == UIInterfaceOrientationLandscapeLeft  ||orientation ==  UIInterfaceOrientationLandscapeRight ) 
{

            return YES;
        }
        return NO;
        }

//for ios5

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    //interfaceOrientation == UIInterfaceOrientationLandscapeRight; 
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft  ||interfaceOrientation ==  UIInterfaceOrientationLandscapeRight ) {

        return YES;
    }
    return NO;
}
于 2013-02-23T13:41:57.920 に答える
-1

ios5 と ios6 の両方で自動回転をサポートするには、ios6 の場合にコールバックを提供する必要があります....`[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

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

そして、私たちは電話する必要があります

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;

}

-(BOOL)shouldAutoRotate{
    return YES;
  }

iOS5用

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

{ return ((toInterfaceOrientation == UIInterfaceOrientationPortrait) || (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)); }

于 2013-08-22T07:29:12.823 に答える