iOS6で自動回転を動作させようとしています。私はすでにそれについて読みました、そして、問題は私がウィンドウのためにrootviewcontrollerを設定することができないということです。私はそれを試しました:
self.window.rootViewController = [[TTNavigator navigator] rootViewController];
しかし、アプリは認識されないセレクターでクラッシュします...
iOS5では、自動回転はshouldAutorotateToInterfaceOrientation
メソッドで正常に機能しました。
3 に答える
次のことを試してください。
[[[UIApplication sharedApplication] keyWindow] setRootViewController:[[TTNavigator ナビゲーター] rootViewController]];
iOS6で自動回転が変わりました。はい、使用した iOS5 ではshouldAutorotateToInterfaceOrientation
。iOS5 をサポートするにはこれも必要ですが、iOS6 をサポートするには、以下の新しいメソッドを追加してください。
これがあなたが求めているものだと思います。
#pragma mark - View Orientation
-(NSUInteger)supportedInterfaceOrientations {
// For iOS6
NSUInteger orientation = 0;
orientation |= UIInterfaceOrientationMaskPortrait;
orientation |= UIInterfaceOrientationMaskPortraitUpsideDown;
orientation |= UIInterfaceOrientationMaskLandscapeLeft;
orientation |= UIInterfaceOrientationMaskLandscapeRight;
return orientation;
}
次に、サポートしたくない行をコメントアウトするか削除します。目的の方向をビットごとに「OR」して、1行で返すことができます。他に 2 つの方法があります。
UIInterfaceOrientationMaskAll
とUIInterfaceOrientationMaskAllButUpsideDown
このチュートリアルは私にとってはうまくいきました: http://www.goodnewtiger.com/llf/cegeek/?p=61
私は TTNavigationController を変更し、アプリデリゲートで viewcontroller を設定しなければなりませんでした。