Pregunta

I am confused about navigation controller, My first View in the application consists of 4 buttons inside, I wanna add a navigation controller to this view so where I push another views to navigation controller according to which buttons is pressed and I can see navigation bar on other views I am redirected.

However I dont want to see the navigation bar on the top for the first view. Is there a way for adding the navigation controller to appdelagete and make the navigation bar not visible for my first screen.

Thanks in advance.

¿Fue útil?

Solución

To add navigation bar in your app

Use following code in didFinishedLaunching:withOptions: of AppDelegate class:

ViewController *homeController = [[HomeController alloc] init];
self.controller = [[UINavigationController alloc] initWithRootViewController:viewController];
[self.window addSubview:self.controller.view];
[self.window makeKeyAndVisible];

In the ViewController's viewWillAppear method, Add the following line of code:

[[self navigationController] setNavigationBarHidden:YES animated:NO];

In the ViewController's viewWillDisappear method, Add the following line of code:

[[self navigationController] setNavigationBarHidden:NO animated:NO];

Otros consejos

Put this below code in your viewWillAppear method to get it called everytime when you return on the first view

[self.navigationController setNavigationBarHidden:YES animated:NO];

and put

[self.navigationController setNavigationBarHidden:NO animated:NO];

in viewDidLoad of next controller you want to push or, you can also place the above code in viewWillDisappear of FirstViewController.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top