0

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.

Reaper
  • 124
  • 2
  • 16

2 Answers2

2

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];
viral
  • 4,168
  • 5
  • 43
  • 68
  • Thanks Viral; There is a small problem though; when I add setNavigationBarHidden:YES, it hides the navigation bar however it hides the navigation bar for the other views I am directed also. Do you have an idea how can I solve that ? – Reaper Apr 03 '13 at 08:55
1

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.

iphonic
  • 12,615
  • 7
  • 60
  • 107