[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

删除行

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

{

    if (editingStyle==UITableViewCellEditingStyleDelete) {

        //        获取选中删除行索引值

        NSInteger row = [indexPath row];

        //        通过获取的索引值删除数组中的值

        [self.arrayimg removeObjectAtIndex:row];

        //        删除单元格的某一行时,在用动画效果实现删除过程

       [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

  

    }

}

 

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath

{

    return UITableViewCellEditingStyleDelete;

}

 

 

[tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic];

删除组

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

{

    if (editingStyle==UITableViewCellEditingStyleDelete) {

        //        获取选中删除行索引值

//        NSInteger row = [indexPath row];

        //        通过获取的索引值删除数组中的值

        NSInteger section = [indexPath section];

        [self.arrayimg removeObjectAtIndex:section];

        //        删除单元格的某一组时,在用动画效果实现删除过程

        //[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

        [tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic];

    }

}

 

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath

{

    return UITableViewCellEditingStyleDelete;

}

相关文章:

  • 2022-03-07
  • 2022-12-23
  • 2022-01-05
  • 2021-11-05
  • 2021-07-21
  • 2021-07-11
  • 2021-09-08
  • 2022-02-02
猜你喜欢
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
相关资源
相似解决方案