【问题标题】:How to remove the edit button on a Master-Detail Template如何删除主从模板上的编辑按钮
【发布时间】:2013-01-09 18:03:40
【问题描述】:

我在界面生成器中使用主从模板创建了一个项目,我想去掉编辑按钮。

我写(在 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];

但是,按钮仍然存在。

【问题讨论】:

    标签: iphone ios objective-c xcode ios6


    【解决方案1】:

    您需要完全移除该按钮。 setEditing 与tableview是否处于编辑模式有关,请尝试:

    self.navigationItem.rightBarButtonItem = nil;
    

    在您的 viewDidLoad 方法中。

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

    self.navigationItem.rightBarButtonItem = self.editButtonItem;
    

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

    【讨论】:

    • 这有帮助,谢谢...任何人看到它实际上是 self.navigationItem.leftBarButtonItem = self.editButtonItem;这是模板的一部分。我不得不删除那条线(duh)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-15
    相关资源
    最近更新 更多