views:

38

answers:

2

i am using this in my view didlod [self.navigationController setNavigationBarHidden:YES]; it hides when applicationn launches but when i navigate to next screen and come back to main view is not hide it navigation bar... why is it like that?

should i add any thing ?

....

+2  A: 

This works for me:

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

- (void) viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

You wouldn't then need the one in viewDidLoad.

If it's not clear from that change, the reason your original code didn't work is that the view may be kept in memory even if it is not on screen - so need to hide / display the navigation bar each time the view is brought on or off screen.

JosephH
yes its works for me,thanks
lak in iphone
i want to add back ground image to navigation controller root view i am using self.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"background.png"]]; its not working
lak in iphone
Glad it's working! You should ask your background image question as a new question so more people see it.
JosephH
k i will add itbut when use your methods to hide navigation bar ,its giving space to move my table view upside ,but i dont want to move up and i should able add image in place of navigation bar ...thanks for that help. in advance..
lak in iphone
can u provide a syntax to add image in place of nav bar
lak in iphone
A: 

viewDidLoad only fires the first time it loads your view. viewWillAppear fires every time.

Bryan