The best solution is to create base classes for UIViewController and UITableViewController and override their init methods. This will allow you to add ViewControllers to the NavigationController programmatically after a rootViewController. If you put this code in the ViewDidLoad method, it will not be called in this case and the next controller will be pushed with a back text.
BaseViewController in Objective C:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#import "BaseViewController.h" @interface BaseViewController () @end @implementation BaseViewController - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; } return self; } @end |
BaseTableViewController:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#import "BaseTableViewController.h" @interface BaseTableViewController () @end @implementation BaseTableViewController - (instancetype)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; } return self; } @end |