uitableview如何折叠下一行呢?
其实实现不难,原理是类似折叠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];
}
效果如下: