Search code examples
objective-cback-button

Objective C - removing default chevron glyph for back button in iOS SDK 8.4


i'm seeking help in removing the default "<" symbol placed before the back button text in a navigation controller going from ViewControllerA to ViewControllerB.

in ViewControllerA i have:

-(void) viewDidLoad
{
    [super viewDidLoad];
    self.navigationItem.backBarButtonItem.title = @"Back to A"
    self.navigationItem.backBarButtonItem.image = nil;
}

the result - when segued into ViewControllerB - is: "< Back to A" in the new navigation controller whereas I want just "Back to A".

any help is much appreciated.


Solution

  • Are you using storyboards? If you are, you get the desired result by drag-dropping a UIBarButtonItem to where the default back button shows up. That's it. Set the desired text and arrow will not show up.

    EDIT:

    To make the custom back button function, connect an IBAction to it.

    in view controller B:

    - (IBAction)backToControllerA {
        [[self navigationController] popViewControllerAnimated:YES];
    }
    

    Connect the action to the button in IB.