0

I want to change the text of the "Edit" and "Done" button which is on the navigation bar, on my iOS app written in objective-c, how can I do that?

Ashley Ivy
  • 193
  • 3
  • 14
  • Did you really made any attempt to write code or have you tried to search on a search engine called @"Google". There are more than 20 question answered on stack-overflow on this issue. – Vizllx Jun 01 '15 at 07:32
  • possible duplicate of [How do I change the title of the "back" button on a Navigation Bar](http://stackoverflow.com/questions/1449339/how-do-i-change-the-title-of-the-back-button-on-a-navigation-bar) – Vizllx Jun 01 '15 at 07:33
  • On tap of barButton, you could change the text self.editButon using setText method. Also don't forget to connect a IBOutlet of your barButton. – nikhil84 Jun 01 '15 at 07:33
  • possible duplicate of [How to change Edit/Done button title in UINavigationBar](http://stackoverflow.com/questions/13429743/how-to-change-edit-done-button-title-in-uinavigationbar) – Nimit Parekh Jun 01 '15 at 07:34
  • possible duplicate of [ http://stackoverflow.com/questions/13429743/how-to-change-edit-done-button-title-in-uinavigationbar ] – Vineeth Joseph Jun 01 '15 at 09:34

2 Answers2

0

This is want you want.

    UIButton *btncustome = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 60, 30)];
    [btncustome setTitle:@"Edit" forState:UIControlStateNormal];
    [btncustome setTitle:@"Done" forState:UIControlStateSelected];

    UIBarButtonItem *rightbtn = [[UIBarButtonItem alloc]initWithCustomView:btncustome] ;
    self.navigationController.navigationItem.rightBarButtonItem = rightbtn;
Ghanshyam Tomar
  • 762
  • 1
  • 8
  • 24
-1

Get the UIBarButton from the UINavigationController and use setTitle method to change the text.

UINavigationItem *items = [[[[self navigationController] navigationBar] items] lastObject];

    UIBarButtonItem *cancelButton = [item leftBarButtonItem];
    UIBarButtonItem *editButton = [item rightBarButtonItem];

    [cancelButton setTitle:@"New Title"];
    [editButton setTitle:@"New Title"];
Ghanshyam Tomar
  • 762
  • 1
  • 8
  • 24
abhishekkharwar
  • 3,529
  • 2
  • 18
  • 31