Pintu
Pintu

Reputation: 369

ViewWillAppear/Disappear not called when the view is created programmatically

I have a root view controller class. This view has few buttons. on the click of the button, I show tab bars. So basically, I have the implementation of tab bar and navigation controls. Basically, I have data that I shown in table view format. The other view are created programmatically.

Now, the problem is on the root view I am able to hide the navigation bar using

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

but, when I click on the buttons, the navigation bar is hidden from on the next view.I tried putting breaks on viewdidappear and viewdiddisapear method but these methods are not fired.

Can you please help me on how to ensure that either these methods are fired or on how to get the navigation controller shown except on the first view.

Upvotes: 2

Views: 1018

Answers (2)

Ishu
Ishu

Reputation: 12787

use

-(void)viewWillAppear:(BOOL)animated and -(void)viewWillDisappear:(BOOL)animated

and on which button click you want hide the tab use

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

before pushing

as you are using and now in viewWillDisappear use

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

Upvotes: 0

Di Wu
Di Wu

Reputation: 6448

Similar problems have been posted onto SO over and over and over. Here is a good explanation, check this post, pay attention to the answer given by @cduhn.

push viewcontroller using UINavigationController sometimes calls viewDidAppear: and viewWillAppear:

Upvotes: 1

Related Questions