Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out if a UIViewController is the root view controller?

basically I want to know if the view controller I'm in is the root view controller or not.

If its not I want to put a button in the nav bar that says "back" (as if it were a proper back button - this bit I know how to do).

Before you ask, I have removed all the titles from my view controllers - I didn't want them to show up on my navigation bar... its very complicated - but this means that when I go through my navigation stack none of the pushed view controllers have a back button. :/

Thanks Tom

like image 487
Thomas Clayson Avatar asked Sep 10 '25 15:09

Thomas Clayson


1 Answers

if ( self != [self.navigationController.viewControllers objectAtIndex:0] )
{
   // Put Back button in navigation bar
}
like image 113
Brian Avatar answered Sep 12 '25 08:09

Brian