星五博客

uitableview折叠下一行(cell)

类似折叠section的效果,只是这回折叠的是同个section下的选中行的下一行。
if (list.count==30) {//这里加个折叠条件,比如放个switch按钮
  [listremoveObjectAtIndex:indexPath.row+1];
  NSIndexPath *nextIndexPath=
    [NSIndexPathindexPathForItem:
      indexPath.item+1inSection:indexPath.section];
  [_tableView deleteRowsAtIndexPaths:
    @[nextIndexPath]withRowAnimation:UITableViewRowAnimationNone];
} else {
  [listinsertObject:
    [[NSStringalloc]initWithFormat:@"标题%ld",indexPath.row+2]
      atIndex:indexPath.row+1];
  NSIndexPath *nextIndexPath=
    [NSIndexPathindexPathForItem:indexPath.item+1inSection:indexPath.section];
  [_tableView insertRowsAtIndexPaths:
    @[nextIndexPath]withRowAnimation:UITableViewRowAnimationNone];
}

IOS