Reputation: 511
i add navigation bar in rootController like below in appdelegate
@property (strong, nonatomic) UINavigationController *navController;
@synthesize navController;
birthDateTableViewController =[[BirthDateTableViewController alloc]initWithNibName:@"BirthDateTableViewController" bundle:nil];
navController = [[[UINavigationController alloc]initWithRootViewController:birthDateTableViewController]autorelease];
[window addSubview:navController.view];
[window makeKeyAndVisible];
return YES;
now as i want to hide it in other view because they have their own navigation bars so i use following code for hiding rootViewControllers navigation bar but its not hiding please tell me what i am doing wrong i do this for hiding in viewDidLoad
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.navController setNavigationBarHidden: YES animated:NO];
application get crash when it reach above line i have tried this which is not working [self.navigationController setNavigationBarHidden: YES animated:NO];
Upvotes: 1
Views: 1664
Reputation: 17535
I think this will work fine..
[self.navigationController setNavigationBarHidden: YES animated:YES];
Upvotes: 0
Reputation: 9836
For iOS < 6.0 use
[self.window addSubview:navigationController.view];
For iOS >= 6.0 use
[self.window setRootViewController:navigationController];
Upvotes: 0
Reputation: 122
Rather using...
[window addSubview:navController.view];
Use this...
[window addSubview:self.navController];
And in your viewControllers, use this...
self.navigationController.navigationBarHidden = YES;
Upvotes: 0
Reputation: 1834
Try this in your view controller's -(void)viewWillAppear method in which you don't want to show navigation bar.
- (void)viewWillAppear:(BOOL)animated
{
self.navigationController.navigationBarHidden = YES;
[super viewWillAppear:animated];
}
Upvotes: 0
Reputation: 1499
Your appDelegate doesn't have a link to the navController but your viewController has one! So change your code for:
[self.navigationController setNavigationBarHidden: YES animated:NO];
Upvotes: 2