What you can do is subclass the navigation controller. Here is an example
@interface NavigationController : UINavigationController
@end
@interface NavigationController () <UINavigationBarDelegate>
@end
@implementation NavigationController
- (void)viewDidLoad
{
[super viewDidLoad];
for (UIViewController* viewController in self.viewControllers){
// You need to do this because the push is not called if you created this controller as part of the storyboard
[self addButton:viewController.navigationItem];
}
}
-(void) pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
[self addButton:viewController.navigationItem];
[super pushViewController:viewController animated:animated];
}
-(void) addButton:(UINavigationItem *)item{
if (item.rightBarButtonItem == nil){
item.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(action:)];
}
}
-(void) action:(UIBarButtonItem*) button{
}
@end