0
votes

This questions look repeated, but I din't got proper solution for my problem. In my case, Once I clicked back button I want to hide the navigation bar. For e.g. View1 pushed view2, view2 will have navigation bar,once I clicked back it brings me back to view 1 it should not contain navigation bar I need to hide it. I tried with viewWillDisappear method in view 2 to hide, it worked but if I have more view and I'm pushing each view from view1 if I click back button,navigation bar should hide in view1. So is anyway is there to know in view 1 itself that other view is popped. I tried viewwillappear method in view1 its not called. What can I do here.?

This method got called once I initially load view1, not after popping view2..

    - (void) viewWillAppear : (BOOL)animated
{
    [root_obj.navigationController setNavigationBarHidden:YES animated:YES];
}

This is how I am pushing view 2..

[root_obj.navigationController pushViewController:view2 animated:NO];

thanks in Advance

2
" I tried viewwillappear method in view1 its not called. " are you sure? I don't see why it shouldn't be called.iNoob
@inoob I tried.. Its not called.Feroz
I've couple of similar applications, in which my first screen doesn't have nav bar, rest of the screens have. In that i've always added nav bar hiding in viewWillAppear and seems to work just fine. Can you show viewWillAppear code if possible?iNoob
Or Way of pushing I done wrong ???Feroz
@FerozMohideen, try doing an NSLog in viewWillAppear, as far as i know viewWillAppear is always called when a view appears.-(void) viewWillAppear : (BOOL)animated { [root_obj.navigationController setNavigationBarHidden:YES animated:YES]; NSLog(@"VIEW WILL APPEAR!!"); [super viewWillAppear:animated]; }, please give this code a go.iNoob

2 Answers

1
votes

i think, u have forgot to call viewWillAppear: method of super class.

-(void) viewWillAppear : (BOOL)animated
{

    [super viewWillAppear:animated];

    [root_obj.navigationController setNavigationBarHidden:YES animated:YES];
}
0
votes

Why don't you hide the NavigationBar in View1's ViewDidAppear method

Edit

I am not sure what the problem with your code but you can do these kind of things in ViewWillAppear or ViewDidAppear methods for more information UIViewController Class Reference and check ViewWillAppear or ViewDidAppear