カスタムを作成していますが、コレクションビューで呼び出すと、すべてのセクションで呼び出されることに気付きUICollectionViewFlowLayout
ました。その結果、新しく追加されたセクションだけでなく、すべてのセクションにアニメーションが適用されます。initialLayoutAttributesForAppearingItemAtIndexPath:
initialLayoutAttributesForAppearingDecorationElementOfKind:atIndexPath:
performBatchUpdates:completion:
[collectionView performBatchUpdates:^{
currentModelArrayIndex++;
[collectionView insertSections:[NSIndexSet indexSetWithIndex:currentModelArrayIndex]];
[collectionView reloadSections:[NSIndexSet indexSetWithIndex:currentModelArrayIndex-1]];
} completion:^(BOOL finished) {
[collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:currentModelArrayIndex] atScrollPosition:UICollectionViewScrollPositionTop animated:YES];
}];
これまでに試したのはperformBatchUpdates:completion:
、単純な更新の代わりにへの呼び出しを削除することですが、既存のセクション(すべて)はとにかくアニメーション化されています。最後のセクションのみのレイアウト属性を変更していることを確認するための解決策を考え出しましたが、それはハックな感じがします。
if (decorationIndexPath.section == [(id<UICollectionViewDataSource>)self.collectionView.delegate numberOfSectionsInCollectionView:self.collectionView] - 1)
{
layoutAttributes.alpha = 0.0f;
layoutAttributes.transform3D = CATransform3DMakeTranslation(-CGRectGetWidth(layoutAttributes.frame), 0, 0);
}
これは、一部のセクションのみをアニメーション化するための適切な方法ですか?