2012-10-03 14 views
0

我有UINavigationController其中我有UITableView和我正在使用editButtonItem编辑UITableVieweditButtonItem 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

是, 如果你想自定义标题,你必须这样做,在

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

采取一个UIBarButtonItem像.h文件中波纹管..

UIBarButtonItem *btnSave; 

在.m文件

-(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 
     } 
} 

我希望这可以帮到你...

:)