0

UINavigationControllerUITableView이 있고, UITableView을 편집하는 데 editButtonItem을 사용하고 있습니다.editButtonItem title이 완료 될 때 기본값으로 재설정됩니다.

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 

    self.editButtonItem.title = @"تحرير"; 
    self.navigationItem.rightBarButtonItem = self.editButtonItem; 
} 

처음 실행에 원하는대로 편집 버튼의 제목이 표시됩니다 :

여기에 코드입니다. 하지만 탭을 누르면 테이블보기가 편집 모드로 들어가고 Done이 표시됩니다. Done을 누르면 제목이 기본값 Edit으로 재설정됩니다.

- (void)setEditing:(BOOL)editing animated:(BOOL)animated; 

또는 그것을 할 수있는 더 좋은 방법이있다 :

내가의 모든 토글의 제목을 설정해야합니까? 또한 편집 모드에서 "완료"텍스트를 변경하려고합니다. 사용자 정의 타이틀을 원하는 경우

답변

2

예, 당신이하는 .m 파일

에 ..
- (void)setEditing:(BOOL)editing animated:(BOOL)animated; 
0

한 .H 파일에서 울부 짖는 소리와 같은 UIBarButtonItem

에 그 이후

UIBarButtonItem *btnSave; 

그것을해야

-(void)viewWillAppear:(BOOL)animated 
{ 
    btnSave = [[UIBarButtonItem alloc]init]; 
    btnSave.target = self; 
    btnSave.action = @selector(btnEdit_Click:); 
    btnSave.title = @"Edit";// here give title which you want... 
    self.navigationController.topViewController.navigationItem.rightBarButtonItem = btnSave; 
} 

-(IBAction)btnEdit_Click:(id)sender 
{ 
     if ([btnSave.title isEqualToString:@"Edit"]) { 
       ///something do here and also change the title of button here 
      [btnSave setTitle:@"Save"];// just for an example 

     } 
     else { 
       ///something do here and also change the title of button here 
       [btnSave setTitle:@"Edit"];//just for an example 
     } 
} 

희망이 ...

:

관련 문제