Eva*_*van 14 iphone cocoa-touch uikit ios uicollectionview
我有一个子类UICollectionViewLayout,将单元格放在一个圆圈中.布局返回YES呼叫shouldInvalidateLayoutForBoundsChange:.旋转时,初始位置的单元格淡出,最终位置的单元格淡入.
通过在我的布局中添加以下代码,我可以禁用淡入淡出,并且项目的圆圈似乎只是随着方向更改而旋转:
- (UICollectionViewLayoutAttributes *)initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)itemIndexPath {
    return nil;
}
- (UICollectionViewLayoutAttributes *)finalLayoutAttributesForDisappearingItemAtIndexPath:(NSIndexPath *)itemIndexPath {
    return [self layoutAttributesForItemAtIndexPath:itemIndexPath];
}
为什么这些方法会在边界变化时调用,因为文档似乎没有暗示它们会这样做?文档似乎表明它们被称为与从集合视图中插入和删除项目相关.
是否有更好的方法可以在旋转期间禁用交叉淡入淡出?
笔记:
initialLayoutAttributesForAppearingItemAtIndexPath:文档声明默认情况下该方法返回nil但调用super返回的非零值.UICollectionView,deleteItemsAtIndexPaths:并且
 moveItemAtIndexPath:toIndexPath:在旋转期间都没有命中它们.Kal*_*lle 10
该UICollectionViewLayout.h文件指出
// This set of methods is called when the collection view undergoes an
     animated transition such as a batch update block or an animated 
     bounds change.
// For each element on screen before the invalidation, 
     finalLayoutAttributesForDisappearingXXX will be called and an 
     animation setup from what is on screen to those final attributes.
// For each element on screen after the invalidation, 
     initialLayoutAttributesForAppearingXXX will be called an an 
     animation setup from those initial attributes to what ends up on 
     screen.
这显然说他们被称为边界变化.而不是删除/插入,"旧状态"和"新状态"似乎更准确.
| 归档时间: | 
 | 
| 查看次数: | 4141 次 | 
| 最近记录: |