Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

iphone - iOS 6 bug: supportedInterfaceOrientations not called when nav controller used as window root

In my mainwindow.xib I have a navigationcontroller. On top of (as a sub item) I have another viewcontroller(homeviewcontroller).

In the nib I have set the window's rootviewcontroller to be this navigationcontroller.

This is deployed to the app store and works perfectly.

Since upgrading to ios6 sdk I am getting orientation issues - basically with this design the supportedInterfaceOrientations method of my homeviewcontroller does not get called when running my app in ios 6 device/simulator.

In order to fix this issue I need to set homeviewcontroller as the window's rootviewcontroller however this is not what I want - I need the navigationcontroller.

How do I get around this annoying bug in ios6?

Update:

I have also tried doing this programmatically - it still doesn't work.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{        
    HomeViewController *homeVC = [[HomeViewController alloc]init];
    UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:homeVC];
    [self.window setRootViewController:navController];

    [self.window makeKeyAndVisible];

    return YES; 
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to subclass UINavigationController and override supportedInterfaceOrientations there.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...