How can I change this title on button?
Asked
Active
Viewed 467 times
0
-
1I think you need to read these messages first. http://stackoverflow.com/search?q=%5Biphone%5D+change+back+button+title – bealex Jan 25 '12 at 21:32
-
I have got action on first page TimetableViewNew *winframe=[[[TimetableViewNew alloc]init]autorelease]; [self.navigationController pushViewController:winframe animated:YES]; after this I have this screen. This button I can't edit – Pavel Jan 25 '12 at 21:41
-
http://stackoverflow.com/questions/1449339/how-do-i-change-the-title-of-the-back-button-on-a-navigation-bar – haberdar Jan 25 '12 at 21:42
-
how I can do this button with triangle http://i27.fastpic.ru/big/2012/0126/7e/22351c547c438c7c0e9f288b0edea57e.jpg – Pavel Jan 25 '12 at 21:56
2 Answers
1
If this is coming from a Navigation controller, setting the title of the parent VC will set the title of the button to that string value.

LJ Wilson
- 14,445
- 5
- 38
- 62
-
I doing this UIBarButtonItem *btnBack = [[UIBarButtonItem alloc] initWithTitle:@"Назад" style:UIBarButtonItemStyleBordered target:self action:@selector(OnClick_btnBack:)]; self.navigationItem.leftBarButtonItem = btnBack; I need this style of button http://i27.fastpic.ru/big/2012/0126/7e/22351c547c438c7c0e9f288b0edea57e.jpg – Pavel Jan 25 '12 at 22:05
-
-
1In the view controller that pushes that view with the button, put this in the viewDidLoad event: self.title=@"Назад"; – LJ Wilson Jan 26 '12 at 11:42
0
The iOS SDK doesn't allow to change the title of the back button.
Instead, you can replace the back button with a custom back button:
+ (void)setBackButtonForViewController:(UIViewController *)vc target:(id)target selector:(SEL)selector
{
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *image = [UIImage imageNamed:@"back_button.png"];
[backButton setImage:image forState:UIControlStateNormal];
backButton.bounds = CGRectMake(0, 0, image.size.width, image.size.height);
UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
[backButton addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
vc.navigationItem.leftBarButtonItem = temporaryBarButtonItem;
vc.navigationItem.hidesBackButton = YES;
[temporaryBarButtonItem release];
}
You can grab the back_button.png image from http://www.teehanlax.com/blog/iphone-4-gui-psd-retina-display/.

adidami
- 11
- 1
- 4
-
It can do with TTButton class with Three20 library, but for my experience add library to XCode and other it is to hard, – Pavel Jan 26 '12 at 19:45
-
I believe the TTButton class also creates a custom back button. If you'll use my code the end result will be the same. – adidami Jan 26 '12 at 20:33