I've created a two splash screen iPhone app. Afterwards user is taken to first view. I've added a UINavigationController. It works perfectly fine.
How do I remove the navigation bar for the opening view alone?
MainWindow
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.splashScreen = [[SplashScreen alloc] initWithNibName:@"SplashScreen" bundle:nil]; if (self.pageController == nil) { openingpage *page=[[openingpage alloc]initWithNibName:@"openingpage" bundle:[NSBundle mainBundle]]; self.pageController = page; [page release]; } [self.navigationController pushViewController:self.pageController animated:YES]; [window addSubview:splashScreen.view]; [splashScreen displayScreen]; [self.window makeKeyAndVisible]; return YES; }
Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.
Use this code and enjoy: NSMutableArray *navigationArray = [[NSMutableArray alloc] initWithArray: self. navigationController. viewControllers]; // [navigationArray removeAllObjects]; // This is just for remove all view controller from navigation stack.
Try this method inside a view controller:
// swift self.navigationController?.setNavigationBarHidden(true, animated: true) // objective-c [self.navigationController setNavigationBarHidden:YES animated:YES];
More clarifications:
UINavigationController
has a property navigationBarHidden, that allows you to hide/show the navigation bar for the whole nav controller.
Let's look at the next hierarchy:
--UINavigationController ------UIViewController1 ------UIViewController2 ------UIViewController3
Each of three UIViewController has the same nav bar since they are in the UINavigationController. For example, you want to hide the bar for the UIViewController2 (actually it doesn't matter in which one), then write in your UIViewController2:
- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:YES]; //it hides the bar } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; // it shows the bar back }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With