Reputation: 1819
I have added a NavigationBar
to View2 with a "Back" item and then I ctrl-dragged from this item to View1 to add a segue
(a show
segue). Now whenever "Back" is used to navigate to View1, I get a navigation bar (with an item "back") to this view (View1). I only want a navigation bar to View2, not View1. I can always hide View1's NavigationBar
programmatically but I am wondering if I am doing something wrong.
Upvotes: 0
Views: 38
Reputation: 978
You need to hide navigation Bar for View1 inside ViewWillAppear and unhide while going to viewWillDisappear:
View1:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController.navigationBar setHidden:true];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController.navigationBar setHidden:false];
}
View2:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController.navigationBar setHidden:false];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController.navigationBar setHidden:true];
}
Any one of class function you can use, either view1 functions or view2 functions to hide and unhide navigation bar while switching controller.
Upvotes: 1