I am developing an IOS
application. I am using navigation controller. If I push to next page then back button title not shown previous page title in IOS 7. Back button title always "Back" in IOS 7. I set all pages titles in viewWillAppear
, viewDidload
like below. But it is not working.
self.navigationItem.title=@"Previous Page Title";
self.title = @"Previous Page Title";
What can I set back button title with previous page title in IOS 7
Thanx
If the title is large, back button shows back only.Try with short titles,like
self.title = @"Test";
if you want Long title , go for custom back button.
In iOS 7 the back button length is constrained (I think to 11 chars). You can set a custom "back button title" like this, for example in viewDidAppear
in the view controller with the long title (not the current view controller!):
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back Title"
style:UIBarButtonItemStylePlain
target:nil
action:nil];
If you want to force to always have the back button, but still let the system create it for you (will handle "Back" localization, abbreviate the button to a single "<" if the current title is really long, etc), then just use an absurdly long back button title:
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@" really long never shown title"
style:UIBarButtonItemStylePlain
target:nil
action:nil];
Try this code:
[[UIBarButtonItem alloc] initWithTitle:@"Your Title Here"
style:UIBarButtonItemStylePlain
target:nil action:nil];
Or you can set an image for button like this:
UIBarButtonItem *barBtn = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"arrow.png"] style:UIBarButtonItemStylePlain target:self action:@selector(back:)];
self.navigationItem.leftBarButtonItem = barBtn;
And @selector method:
-(void)back:(id)sender{
[self.navigationController popViewControllerAnimated:YES];
}