質問

私はアプリに取り組んでいます。アプリの方向はランドスケープですが、アプリのインターフェイスを実行した後、アプリの方向はインターフェイスを変更して回転させます。正しい方法でのスプラッシュ画面表示(風景)。 iOS7を使用しているアプリはiOS5のコードでした。たとえば、最新のiOSではこれ以上利用できないために呼び出されるsefrotatetointerfaceorientationボットなどの非推奨APIの問題があると思います

enter image description here

役に立ちましたか?

解決

すべてのナビゲーションコントローラーがトップビューコントローラーを尊重するようにしたい場合は、カテゴリを使用して、クラス名を積んで変更する必要がないようにします。

 @implementation UINavigationController (Rotation_IOS6)

-(BOOL)shouldAutorotate
{
   return [[self.viewControllers lastObject] shouldAutorotate];
 } 

-(NSUInteger)supportedInterfaceOrientations
{
    return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [[self.viewControllers lastObject]     preferredInterfaceOrientationForPresentation];
}

@end

コメントのいくつかが指摘しているように、これは問題の簡単な修正です。より良いソリューションは、サブクラスUinavigationControllerであり、これらの方法をそこに置きます。サブクラスは、6と7をサポートするのにも役立ちます。

他のヒント

enter image description here

ビルドでOrintatoinを設定する必要があります。

それはあなたの問題を解決します。

これを試して:

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}

編集 :

添付を参照してください リンク, 、あなたに役立つかもしれません。

私がしていると思う解決策があると思います。ステップ1は、カテゴリを作成してUinavigationControllerをオーバーライドします

ステップ2の交換[self.window addsubview:[NavigationController View]]; //年

self.window setrootviewcontroller:navigationcontroller]; //新着

これをappdelegate.mで使用します

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    NSLog(@"Interface orientations");
    if([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPad ){

        return UIInterfaceOrientationMaskLandScape;
    }
    else{
        return UIInterfaceOrientationMaskPortrait;
    }
}

それは私を助けてくれました。

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