Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UICollectionViewFlowLayout数据集之间的动画_Ios_Objective C_Animation_Uicollectionview - Fatal编程技术网

Ios UICollectionViewFlowLayout数据集之间的动画

Ios UICollectionViewFlowLayout数据集之间的动画,ios,objective-c,animation,uicollectionview,Ios,Objective C,Animation,Uicollectionview,我有一个UICollectionView,当按下一个单元格时,将有一组新的数据,并将为流布局设置动画 -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { NSMutableArray *tempArray = [[NSMutableArray alloc] init]; for(int i=0;i<200;i+

我有一个UICollectionView,当按下一个单元格时,将有一组新的数据,并将为流布局设置动画

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSMutableArray *tempArray = [[NSMutableArray alloc] init];
    for(int i=0;i<200;i++)
    {
        [tempArray addObject:[NSNumber numberWithInt:i]];
    }

    items = [NSArray arrayWithArray:tempArray];

   CollapseLayout *currentLayout = (CollapseLayout *)_collectionView.collectionViewLayout;
currentLayout.collapse = YES;
[self.collectionView performBatchUpdates:^{
    [self.collectionView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.collectionView.numberOfSections)]];
} completion:nil];
}
乡下人

_collapse 
在“我的收藏”视图中调用“已设置”以触发动画。我希望旧的细胞,从左向右移动,在视图之外,新的细胞从屏幕的右侧进入动画。现在,细胞刚刚离开屏幕

我的问题是layoutAttributesForItemAtIndexPath和layoutAttributesForElementsInRect中的代码动画设置不正确。在这些方法中添加动画代码是执行动画的最佳位置,还是完全关闭?
谢谢

你不应该做任何事情来破坏你的工作成果

[super layoutAttributesForItemAtIndexPath:indexPath];
也不是

如果希望单元格从屏幕外的位置开始设置动画,则只需修改其“最终”位置,方法是覆盖
finalattributesfordisappearinglementindepath:
,而不是覆盖其“常规位置”


如果你想让他们从屏幕的侧面回来,那么你需要通过
初始布局attributes for AppearinGitematindexPath:

啊,就是这样!谢谢
[super layoutAttributesForItemAtIndexPath:indexPath];
[super layoutAttributesForElementsInRect:rect];