Search code examples
iosuinavigationbaruinavigationitem

Back-like arrow on iOS 7


I need to add a left bar button item in my app that looks like system back button, but is not the system back button, since it will appear on view controller that is the only vc of my navController's stack and execute my own code. Simply writing "Back" isn't really good for me, as I need to display the "<" arrow as well. Is there a way to programmatically create an arrow like that, without making image with that arrow?

This is how it's supposed to look like


Solution

  • Consider using a dummy UIViewController as a root view controller for your UINavigationController’s stack:

     [[UINavigationController alloc] initWithRootViewController:[UIViewController new]];
     [navController pushViewController:viewController animated:NO];
    

    Then you can use my BackButtonHandler extension to handle back button action (as described in this thread) :

     -(BOOL) navigationShouldPopOnBackButton {
          [self dismissModalViewControllerAnimated:YES];
          return NO; 
     }