UITableView的setEditing为NO不会改变barButtonItem [英] UITableView setEditing to NO doesn't change barButtonItem back

查看:201
本文介绍了UITableView的setEditing为NO不会改变barButtonItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 UINavigationController 里有一个 UITableViewController 。我将 rightBarButtonItem 设置为编辑按钮:

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

self.navigationItem.rightBarButtonItem = self.editButtonItem;

这很好,我调用 tableView:commitEditingStyle:forRowAtIndexPath:我以编程方式使用以下方式更改我的 tableView :编辑模式:

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];

这里奇怪的是, barButtonItem 仍然似乎在编辑模式,因为它仍然说完成像它在我在编辑模式时。点击它将按钮更改回编辑,然后我必须再次点击重新进入编辑模式。

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.

为什么不是 barButtonItem 从编辑模式改变?

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

推荐答案

按钮控制视图控制器的编辑模式将其传递到表视图。您正在使表视图直接退出编辑模式,而不是告诉视图控制器。尝试在 self 而不是 self.tableView 上设置编辑模式。

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.

这篇关于UITableView的setEditing为NO不会改变barButtonItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆