Iphone 如何将barbuttonitem从“编辑”更改为“完成”

Iphone 如何将barbuttonitem从“编辑”更改为“完成”,iphone,Iphone,我正在使用“编辑”按钮将工具栏放置在视图顶部 对于编辑按钮,我给出了如下所示的编辑表格的操作 - (IBAction)editModeForTable { [tableview setEditing:YES animated:YES]; NSLog(@"edit button clicked "); } 现在我需要的是,当我点击编辑按钮时,我需要将这个编辑按钮更改为完成按钮 这是我的屏幕 当我点击编辑时,我需要为表格设置编辑模式,并将编辑按钮更改为“完成” 类似地,当我点击“

我正在使用“编辑”按钮将工具栏放置在视图顶部

对于编辑按钮,我给出了如下所示的编辑表格的操作

- (IBAction)editModeForTable {
    [tableview setEditing:YES animated:YES];
    NSLog(@"edit button clicked ");
}
现在我需要的是,当我点击编辑按钮时,我需要将这个编辑按钮更改为完成按钮

这是我的屏幕

当我点击编辑时,我需要为表格设置编辑模式,并将编辑按钮更改为“完成”

类似地,当我点击“完成”按钮时,我需要更改“完成编辑”按钮,编辑模式应为false

更新:

- (IBAction)editModeForTable {
    if (buttonClickid == 1) {
        [allLIsts setEditing:YES animated:YES];
        mybutton.style = UIBarButtonSystemItemDone;
        mybutton.title = @"Done";
        buttonClickid = 2;
        NSLog(@"mmm");
    }
    if (buttonClickid == 2) {
        [allLIsts setEditing:NO animated:YES];
        mybutton.style = UIBarButtonSystemItemEdit;
        mybutton.title = @"Edit";
        buttonClickid = 1;
        NSLog(@"ppp");
    }


    NSLog(@"edit button clicked ");

}
这是buttonclickid为int的按钮操作

它执行这两个条件为什么

[btn setStyle:UIBarButtonItemStyleDone];
[btn setTitle:@"Done"];
类似于恢复。 btn是连接到Interface Builder中的按钮或您创建的UIBarButtonItem的IBOutlet

你的逻辑被打破了

- (IBAction)editModeForTable {
    if (![allLIsts isEditing]) {
        [allLIsts setEditing:YES animated:YES];
        mybutton.style = UIBarButtonSystemItemDone;
        mybutton.title = @"Done";
        NSLog(@"mmm");
    }
    else  {
        [allLIsts setEditing:NO animated:YES];
        mybutton.style = UIBarButtonSystemItemEdit;
        mybutton.title = @"Edit";
        NSLog(@"ppp");
    }


    NSLog(@"edit button clicked ");

}
类似于恢复。 btn是连接到Interface Builder中的按钮或您创建的UIBarButtonItem的IBOutlet

你的逻辑被打破了

- (IBAction)editModeForTable {
    if (![allLIsts isEditing]) {
        [allLIsts setEditing:YES animated:YES];
        mybutton.style = UIBarButtonSystemItemDone;
        mybutton.title = @"Done";
        NSLog(@"mmm");
    }
    else  {
        [allLIsts setEditing:NO animated:YES];
        mybutton.style = UIBarButtonSystemItemEdit;
        mybutton.title = @"Edit";
        NSLog(@"ppp");
    }


    NSLog(@"edit button clicked ");

}