系统在调用 endInteractiveMovement 之后会做一个动画(把 cell 放到它应该在的位置)然后调用一次 cellForItem 确保显示正常。
过程是 endInteractiveMovement
→animation
→cellForItem
如果在 endInteractiveMovement
中调用 reloadData
并不会保证所有 Cell
都得到刷新。
##解决方案
###Step1
在Move回调用记录一个标志位。
1 | -(NSIndexPath *)collectionView:(UICollectionView *)collectionView targetIndexPathForMoveFromItemAtIndexPath:(NSIndexPath *)originalIndexPath toProposedIndexPath:(NSIndexPath *)proposedIndexPath |
###Step2
在 cellForItem 判断这个标志位
Step3
如果满足标志位,再 reload
1 | dispatch_async(dispatch_get_main_queue(), ^{ |