Reputation: 7644
I started out with a navigation based project and am pushing further views onto the controller. The problem is that if I do not give a title to the navigation item then the back button is not drawn! Only if I give the navigation bar a title, will the back button come. It seems apple could'nt write "back" or "go back" in case of NO title. I do not want to give the navigation item a title(I'll use a label inside my view). So how do I fix this?
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"Home"; /// <- without setting the title, the back button won't show !
}
In the view didLoad method, if I remove the title, the back button won't show
Upvotes: 1
Views: 10178
Reputation: 20980
Just create the back button yourself:
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonItemStylePlain
target:nil
action:nil];
[[self navigationItem] setBackBarButtonItem:back];
[back release];
}
(If you prefer dot notation, self.navigationItem.backBarButtonItem = back;
)
Upvotes: 2