1

我使用主从模板在界面构建器中创建了一个项目,我想摆脱编辑按钮。

我写(在 MasterViewController 中):

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return NO;
}

这会禁用编辑按钮,但该按钮仍然存在。

然后我尝试了(在 viewDidLoad 中,将 tableView 属性连接到我的 MasterViewController 类之后):

 [self.tableView setEditing:NO];

但是,按钮仍然存在。

4

1 回答 1

1

您需要完全删除该按钮。setEditing与表格视图是否处于编辑模式有关,因此请尝试:

self.navigationItem.rightBarButtonItem = nil;

在你的viewDidLoad方法中。

还要确保在 viewDidLoad 中没有看到如下代码行:

self.navigationItem.rightBarButtonItem = self.editButtonItem;

如果是,请删除或注释掉。

于 2013-01-09T18:18:02.037 回答