0

I'm adding the following code to my application in order to navigate back and forth from a quicklook view.

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

[self rotateView];
nav = [[UINavigationController alloc] initWithRootViewController:self];

[window addSubview:[nav view]];
[window makeKeyAndVisible];

[[self navigationController] setNavigationBarHidden:YES];

This code is run in my main ViewController viewDidLoad function. My application runs in landscape but this window and navigation bar loads in portrait mode. My application doesn't have a statusBar so some code I've found doesn't work. I get an error if I try to check and listen for status bar orientation notifications.

I'm looking for a way to allow this navigation view to set it's orientation based on the apps current orientation.

4

1 回答 1

0

如果我理解你的问题你上面的代码应该放在didFinishLaunchingWithOptions不在里面viewDidLoadAppDelegate并且 MainViewController 的初始化也应该在那里。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    self.mainViewController = //init your MainViewController;
    navigationController = [[UINavigationController alloc] initWithRootViewController:(UIViewController*)viewController];
    [window addSubview:navigationController.view];
    [self.window makeKeyAndVisible];
    return YES;
}
于 2013-08-09T21:57:35.223 回答