gpt4 book ai didi

ios - 使用 targetIndexPathForMoveFromItemAtIndexPath : 时 UICollectionView 重新排序错误

转载 作者:行者123 更新时间:2023-11-29 00:38:41 25 4
gpt4 key购买 nike

我似乎找不到任何解决以下错误的方法。我在通常的 UIViewController 中使用 Collection View ,并使用新的 ios9 功能进行交互式重新排序。我还定义了可以使用 targetIndexPathForMoveFromItemAtIndexPath: 移动所选单元格的位置。

该错误是当 targetIndex 在 collectionView 中不可见时,移动单元格会在触摸结束的位置留下其自身的副本。 Please see bug scrren shot here .灰色单元格不允许放在粉红色单元格之间,它应该放在最后一个灰色单元格之后,因为它在 View 的开头而不可见。

我还使用本文中的摆动动画进行重新排序。 https://littlebitesofcocoa.com/104-interactive-collection-view-re-ordering

如果您需要我定义手势识别器的代码,这里是

if (gesture.state==UIGestureRecognizerStateBegan){
NSIndexPath *selectedIndexPath = [self.collectionView indexPathForItemAtPoint:[gesture locationInView:self.collectionView]];

if(!selectedIndexPath)
return;

movingIndexPath=selectedIndexPath;

[self setEditing:YES];
[self.collectionView beginInteractiveMovementForItemAtIndexPath:selectedIndexPath];

TLTimelineCollectionCell *pickedCell=[self pickedUpCell];
movingCollectionCell=pickedCell;
[pickedCell stopWiggling];
[self animatePickingUpCell:pickedCell];
UICollectionViewLayoutAttributes *attributes = [self.collectionView layoutAttributesForItemAtIndexPath:selectedIndexPath];

CGRect cellRect = attributes.frame;
CGRect rect=[self.collectionView convertRect:cellRect toView:self.collectionView];


} else if (gesture.state==UIGestureRecognizerStateChanged) {
[self.collectionView updateInteractiveMovementTargetPosition:CGPointMake([gesture locationInView:gesture.view].x,39)];

} else {
if (gesture.state==UIGestureRecognizerStateEnded) {
[self.collectionView endInteractiveMovement];
} else {
[self.collectionView cancelInteractiveMovement];
}

[self animatePuttingDownCell:movingCollectionCell];
movingIndexPath=nil;
movingCollectionCell=nil;

[self setEditing:NO];
}

感谢任何帮助,谢谢!

更新

发现在只有一个 Collection View Controller 的清晰项目中没有任何“摆动动画”的情况下也会发生此错误

最佳答案

原来这是 iOS 9 的错误。在 iOS 10 上运行良好。

关于ios - 使用 targetIndexPathForMoveFromItemAtIndexPath : 时 UICollectionView 重新排序错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40011505/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com