简体   繁体   中英

iOS - How to not show a navigation bar on a screen?

I'm looking for a way to have a navigation bar not show up on a screen at all.

I know there is a setNavigationBarHidden:animated: to use on the navigationbar, but this still shows the bar on the screen for a split second before removing and readjusting the screen dimensions.

I've tried moving the setNavigationBarHidden:animated: to the viewDidLoad: , viewWillAppear: etc. and set it hidden on the previous activities viewWillDisappear: but it will shows up on the next screen.

How do I make it such that the view loads with out a navigationbar on it before it is shown?

Thanks, Dman

I'm hiding the navigation bar for the UINavigationController in the AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method and works fine for me. At some point, while navigating through the screens, I'm showing it then hide it again. Works like a charm.

UIViewController *controller = [[UIViewController alloc] init];
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController: controller];
navCtrl.navigationBarHidden = YES;

self.window.rootViewController = navCtrl;
[controller release];
[navCtrl release];

Hope this helps.

PS Actually I never show the navigationBar of the navigation controller again. On the controllers that need the bar I'm adding a new one.

You could try and do

setNavigationBarHidden:animated:

in your view which is calling the view where you don't want it to be displayed just before you call your new view. If they have the same navigationcontroller, it should already be hidden if it appears

if not, you try to set it on the navigation oder viewcontroller before your present it...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM