views:

885

answers:

4

Weird problem: After rotating my app to portrait, picking the toolbar item and exposing the uipopovercontroller, if I rotate back to landscape, the UINavigationController on the right side (objectAtIndex:0 of the SplitView) changes the color of the navigation bar. I am not sure why. I have it set in Interface Builder to be barStyle = UIBarStyleBlackOpaque;

It turns silver after it returns to landscape mode.

This only happens if I rotate it to portrait, create the popover, and select something in the navigation controller, which pushes another tableViewController. Even setting the properties in the viewDidLoad method does nothing.

Anyone have an idea?

+4  A: 

viewDidLoad will only get called the first time your view is displayed (or if it's cleared due to memory issues). Try re-setting the barStyle in your viewWillAppear, or even – splitViewController:willShowViewController:invalidatingBarButtonItem:.

Ben Gottlieb
Thanks, that worked! In viewWillAppear - self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
JustinXXVII
Remember, as an aside, in viewWillUnload or dealloc, remember to set IBOutlets to nil so as to enable reclamation of resources when the OS/Nav/Tabbar Controller decide to unload that view. Without this step you have a possibility of weird memory leaks later.
Jann
+1 to Jann, people always forget this.
Tilo Mitra
A: 

This didn't work for me. I wonder why.

I placed "self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;" under viewWillAppear in all my views, and still nothing. It's black on first launch, but after I pick a view from the toolbar button while in portrait mode, and turn back to landscape, my navbar changes to silver, not black.

I even placed it in my rootviewcontroller, and nothing.

RyeMAC3
I even tried to set it under my .plist, and still, nothing.
RyeMAC3
A: 

Cool, fixed it.

Added to my RootViewController where the splitviewcontroller and nav bar is declared:

  • (void)viewWillAppear:(BOOL)animated {

    [super viewWillAppear:YES];

    self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;

}

RyeMAC3