To hide the back button and add a left button -
[self.navigationItem setHidesBackButton:TRUE];
UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector()];
[self.navigationItem setLeftBarButtonItem:leftBarButton];
[leftBarButton release];
And then, to programmatically return to the previous view controller, you can do -
[self.navigationController popViewControllerAnimated:YES]
source
share