forkingdog / UITableView-FDTemplateLayoutCell

Template auto layout cell for automatically UITableViewCell height calculating
MIT License
9.94k stars 2.01k forks source link

添加MoveCell的方法约束错误 #306

Closed xlsd closed 7 years ago

xlsd commented 7 years ago

给Demo工程添加Cell置顶的功能后,所有的cell高度出错。

- (void)moveWithIndexPath:(NSIndexPath *)indexPath {
    if (!indexPath) return;

    FDFeedEntity *feedEntity = self.feedEntitySections[indexPath.section][indexPath.row];
    [self.feedEntitySections[indexPath.section] removeObjectAtIndex:indexPath.row];
    [self.feedEntitySections[0] insertObject:feedEntity atIndex:0];

    [self.tableView moveRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section] toIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];

}
xlsd commented 7 years ago
but when I use methed
[self.tableView reloadData]
 to replace this methed
[self.tableView moveRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section] toIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]], 
the rowHeight is ok;
weekwood commented 7 years ago

@giveMeHug

You can combine row-move operations with row-insertion and row-deletion operations within a beginUpdates–endUpdates block to have all changes occur together as a single animation. Unlike the row-insertion and row-deletion methods, this method does not take an animation parameter. For rows that are moved, the moved row animates straight from the starting position to the ending position. Also unlike the other methods, this method allows only one row to be moved per call. If you want multiple rows moved, you can call this method repeatedly within a beginUpdates–endUpdates block.

weekwood commented 7 years ago

let me know if still now working