Reputation: 237
I have a UITableViewController
as the root view controller
of a UINavigationController
.
When the app launches, there is no back bar button on the navigation bar. However, when I click on one of the table view cells, and then click back, a back bar button appears at the top of the original UITableViewController
. I don't want this. How can I get rid of this?
Upvotes: 1
Views: 242
Reputation: 1472
When your application opens up, the UITableViewController
doesn't show a Back
button because there is nothing to go back to. That's the Initial View Controller.
As for the second UIViewController
that pushes on top of the previous UITableViewController
- if you don't want the Back
button in that - use a Modal
transfer and not a Push
transfer.
Apple's Navigation Controller
simply functions like that. It works like a stack. One UIViewController
gets pushed on the current one.
However, if you still want a Navigation Bar
on top of the Modal
segue UIViewController
you can manually add it in the Interface Builder
:
And then you can add a UIBarButton
to the Navigation Bar
.
But if you are still adamant on simply hiding the Back
button, then use this method :
Put this in the viewDidLoad
method of your UIViewController
class's implementation :
[self.viewController setHidesBackButton:YES animated:NO];
Upvotes: 0
Reputation: 12663
On any view controllers that you don't want the back button to show, you can add this to the viewDidLoad
method:
[self.navigationItem setHidesBackButton:YES animated:NO];
Alternatively, you can add this call in viewWillAppear:(BOOL)animated:
if you want the change to be animated:
[self.navigationItem setHidesBackButton:YES animated:animated];
Upvotes: 1