开发者

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 fir开发者_如何学编程st view.


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:


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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜