5

iOS 6.0 ベータ版を使用していますが、ローテーションが機能しなくなりました。

UINavigationControllers supportedOrientations はどこで設定できますか?

このhttp://news.yahoo.com/apple-ios-6-beta-3-changes-182849903.htmlによると 、UINavigation コントローラーは、自動回転するかどうかを決定するために子供たちに相談しません。

shouldAutorotateToInterfaceOrientation: は廃止されたため、もう使用していません。代わりに、supportedInterfaceOrientations: と shouldAutoRotate: を使用しており、ViewController を NavigationController に (子として) 配置するまで、正常に動作しています。それ以降、ViewController で指定された方向は機能しなくなります。ナビゲーションコントローラー(UIInterfaceOrientationMaskAllButUpsideDown)によって設定された向きを使用しているようです

ViewControllers が Portrait-Orientation にロックされるように、NavigationController の InterfaceOrientations を設定するにはどうすればよいですか?

UINavigationController をサブクラス化し、そこに InterfaceOrientations を設定する必要がありますか? iOS 6.0 のまま UINavigationController をサブクラス化するのは悪い習慣ではありませんか?

助けてくれてありがとう!

乾杯!

4

2 に答える 2

9

もう一度子を調べたい場合は、 UINavigationController にカテゴリを追加できます

@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
于 2012-09-22T01:10:14.067 に答える
4

サブクラス UINavigationController

//OnlyPortraitNavigationController.h

@interface OnlyPortraitNavigationController : UINavigationController

//OnlyPortraitNavigationController.m

@implementation OnlyPortraitNavigationController

- (BOOL)shouldAutorotate {
    return NO;
}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait; //for locked only Portrait
}

縦向きのViewControllerで新しいサブクラスのnavigationControllerを提示する

SomeViewController *onlyPortraitVC = [[SomeViewController alloc]init];

OnlyPortraitNavigationController *portraitNav = [[OnlyPortraitNavigationController alloc]initWithRootViewController:onlyPortraitViewController];

[self presentViewController:portraitNav animated:YES completion:NULL];

これは私のアプリでの作業です。お役に立てば幸いです。

于 2012-09-17T05:11:35.297 に答える