简体   繁体   中英

UITableView setEditing to NO doesn't change barButtonItem back

I have a UITableViewController inside of a UINavigationController . I am setting the rightBarButtonItem to the editing button:

self.navigationItem.rightBarButtonItem = self.editButtonItem;

在此处输入图片说明

This works great, and after I call tableView:commitEditingStyle:forRowAtIndexPath: I programmatically change my tableView out of editing mode using:

[self.tableView setEditing:NO animated:YES];

The strange thing here is, the barButtonItem still seems to be in "edit mode" as it still says "Done" like it does when I am in editing mode. Clicking it changes the button back to "Edit", then I have to click AGAIN to take it back into edit mode.

在此处输入图片说明

Why isn't the barButtonItem getting changed from editing mode as well?

The button controls the editing mode of the view controller, which is passing it onto the table view. You are taking the table view directly out of editing mode and not telling the view controller. Try setting the editing mode on self instead of self.tableView .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM