Answer:
After spending a day for this problem, I have a fairly simple and easy solution, it works on both iOS 6 and iOS 7:
1). Custom style (color, font) in AppDelegate (suppose you use the same style for all controllers)
2). Create a custom UINavigationController as follows:
CustomBackNavigationController.h
@interface CustomBackNavigationController : UINavigationController <UINavigationControllerDelegate>
@property (nonatomic, strong) UIBarButtonItem *backButton;
@end
CustomBackNavigationController.m
@implementation CustomBackNavigationController
@synthesize backButton;
- (void)viewDidLoad
{
[super viewDidLoad];
self.delegate = self;
}
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
backButton = [[UIBarButtonItem alloc] initWithTitle:@"Chats" style:UIBarButtonItemStyleBordered target:nil action:nil];
viewController.navigationItem.backBarButtonItem = backButton;
}
@end
in the dropdown view controllers, just change the backButton header like this
- (void)someMethod
{
CustomBackNavigationController *customBackNavigationController = (CustomBackNavigationController *) self.navigationController;
[customBackNavigationController.backButton setTitle:@"Chats (1)"];
}
What is it!
source
share