UITableView setEditing to NO doesn't change barButtonItem back

烂漫一生 提交于 2020-01-16 00:41:13

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/11490575/uitableview-setediting-to-no-doesnt-change-barbuttonitem-back

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!