【问题标题】:UITableView editing: Cell edits, but delete button does not show upUITableView 编辑:单元格编辑,但删除按钮不显示
【发布时间】:2014-09-24 17:27:46
【问题描述】:

代码如下:

-(void)buttonEditPressed:(id)sender{

    if(_tableView.isEditing){

        [_tableView setEditing:NO animated:YES];
        [_buttonEdit setTitle:@"Edit" forState:UIControlStateNormal];

    } else {

        [_tableView setEditing:YES animated:YES];
        [_buttonEdit setTitle:@"Done" forState:UIControlStateNormal];
    }

    [_tableView reloadData];

}

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

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    DLog(@"");
    return UITableViewCellEditingStyleDelete;
}


- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}


-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{

    //Delete the rows at the Indexpath.

    //edit data model 

    [_tableView reloadData];

}

结果如下:

滑动删除作品。但是,当按下编辑按钮时,单元格会向右移动,显示左侧红色删除按钮的空间,但该按钮永远不会出现!

我该怎么办?

【问题讨论】:

    标签: ios objective-c uitableview edit


    【解决方案1】:

    试试这个库:https://github.com/CEWendel/SWTableViewCell

    它有很好的文档记录,易于使用,非常适合您的需求。

    【讨论】:

    • 感谢您的建议!老实说,我宁愿手动创建一个按钮,而不是使用一个全新的库 =/ 不过感谢您的建议!
    • 代码中的问题是您没有为左侧定义任何视图/按钮..
    • 哦..等等..现在我明白了..处于编辑状态..删除按钮没有出现..它应该出现一个选择框..你必须实现一个按钮删除所有选定的 indexPaths。老实说,我不确定该怎么做.. 尝试查看使用此功能的其他应用
    猜你喜欢
    • 2017-09-28
    • 1970-01-01
    • 2010-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多