UITableView编辑状态-删除

#pragma mark 删除

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

- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
    // 添加一个删除按钮
    UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
        /// todo
    }];
    return @[deleteRowAction];
}

发布了804 篇原创文章 · 获赞 135 · 访问量 142万+

猜你喜欢

转载自blog.csdn.net/potato512/article/details/103363276