1

I am having an issue when im using navigation controller. My program is laid out where I have a start screen (not in the navigation controller) and then when you press a button it sends you to the navigationController and new view.

Is there a way to get back out of the navigation controller back to that home screen using a back button.

OR if i included the start screen as the root for the navigation controller is there a way to hide the top bar in the view.

The reason i didn't include the start screen originally is because I didn't want the navigation bar on the screen.

Thanks.

crychair
  • 337
  • 3
  • 20
  • Yes you can hide the navigation bar just put this code in your viewDidLoad method in home screen or your start screen where you want to hide it.. – SachinVsSachin Dec 10 '12 at 05:44

7 Answers7

2

For hide the UINavigationBar then use bellow line in viewWillAppear: method of your start screen viewController..

[self.navigationController setNavigationBarHidden:YES]; 

OR

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

AND you can go back to previous view and also home screen or parent view with bellow code...

-(IBAction)yourButton_Clicked:(id)sender{

    [self.navigationController popViewControllerAnimated:YES];//// For back to Previous view
  //  [self.navigationController popToRootViewControllerAnimated:YES]; // For Back to home screen or parent view

}
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
0

Well there is a very simple method to just hide the UINavigationBar when you want to like this in the ant view :-

[self.navigationController setNavigationBarHidden:YES];

and the in the view in which you would want to show it simply unhide it like this :-

[self.navigationController setNavigationBarHidden:NO];
IronManGill
  • 7,222
  • 2
  • 31
  • 52
0

You can use navigation bar in all screens. But for the screen where you dont want to show it, Just use hide property for navigation bar. That screen will not show navigation bar on top.

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

It'll resolve your issue.

iCreative
  • 1,499
  • 1
  • 9
  • 22
0
   - (void) viewWillAppear:(BOOL)animated{

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

         [super viewWillAppear:animated];
 }

- (void) viewWillDisappear:(BOOL)animated{

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

[super viewWillDisappear:animated];
}

By implementing this on your home Screen you can hide the top bar

Lochana Ragupathy
  • 4,320
  • 2
  • 25
  • 36
0

U can hide the navigation bar using

self.navigationController.navigationBarHidden = YES;

Add the start screen as sub view to navigation's root view controller.

[self.view addSubview:startScreen.view]

Later Remove it by [startScreen.view removFromSuperview] and set the navigationBarHidden flag to NO.

Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
cancerian
  • 942
  • 1
  • 10
  • 18
0

If you're using storyboard you could create a UIButton and link the view back modally.

Also check out https://stackoverflow.com/a/8348527/401787 for navigating between view controllers.

Community
  • 1
  • 1
Macness
  • 1,226
  • 2
  • 13
  • 24
0

Actually your requirement are not clearer. But to hide your navigation controller you can use,

self.navigationController.navigationBarHidden=YES;

and also you can add your custom button on to the navigation bar.

UIBarButtonItem *leftBtn=[[UIBarButtonItem alloc]initWithTitle:@"Back" style:UIBarButtonSystemItemAction target:self action:@selector(backBtnClicked:)];
    self.navigationItem.leftBarButtonItem=leftBtn;

and you can right your requirements in the backBtnClicked: method. you can also navigate to your root level view controller.

Paras Joshi
  • 20,427
  • 11
  • 57
  • 70