【问题标题】:Delete Cell without edit button in table view?在表格视图中删除没有编辑按钮的单元格?
【发布时间】:2009-10-01 04:42:45
【问题描述】:

如果我在表格视图中按下特定单元格(编辑按钮的操作将在不按下编辑按钮的情况下执行)。请你回答好吗? 以下代码给出错误...

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    NSArray *deleteIndexPaths =[NSArray arrayWithObjects: 
    [NSIndexPath indexPathForRow:indexPath.row inSection:0],nil]; 
    UITableView *tv = (UITableView *)self.view;
    [tv beginUpdates];

   [tv deleteRowsAtIndexPaths:deleteIndexPathswithRowAnimation:UITableViewRowAnimationFade];
   [tv endUpdates];

}

【问题讨论】:

标签: iphone


【解决方案1】:

您还需要从数据源中删除该单元格的源,因为 tableview 将在更新后尝试重新加载数据。基本上你需要更新

的结果
    numberOfSectionsInTableView

和 numberOfRowsInSection

以便在更新后具有相关性。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多