【发布时间】:2015-06-20 17:38:00
【问题描述】:
我在这个问题上写了更多detailed blog post,但这是要点。我在另一个 UIViewController 中嵌入了 UICollectionView。当容器视图改变它的边界时,集合视图也改变它的边界,这也会触发它的 UICollectionViewLayout 重新布局。
一切都很好,只是单元格不使用旧边界重新使用新框架和布局。 这是来自重要方法的日志,很明显 layoutSubviews 使用了错误的(旧)框架。
__57-[RTColumnViewController processCalculatorKeypadVisible:]_block_invoke
-[RTUnitLayout shouldInvalidateLayoutForBoundsChange:] : YES, {{0, 1014}, {272, 375}} -> {{0, 1014}, {175, 375}}
-[RTUnitLayout prepareLayout], bounds={{0, 1014}, {175, 375}}, itemsize={175, 89}
-[RTUnitLayout prepareForAnimatedBoundsChange:] : {{0, 1014}, {272, 375}} -> {{0, 1014}, {175, 375}}
-[RTUnitLayout layoutAttributesForElementsInRect:] : rect={{0, 667}, {175, 1334}}
__50-[RTUnitLayout layoutAttributesForElementsInRect:]_block_invoke_2 : <NSIndexPath: 0xc000000000048016> {length = 2, path = 0 - 9} frame={{0, 801}, {175, 89}}
__50-[RTUnitLayout layoutAttributesForElementsInRect:]_block_invoke_2 : <NSIndexPath: 0xc000000000058016> {length = 2, path = 0 - 11} frame={{0, 979}, {175, 89}}
...
-[RTUnitLayout finalLayoutAttributesForDisappearingItemAtIndexPath:] : <NSIndexPath: 0xc000000000058016> {length = 2, path = 0 - 11} frame={{0, 979}, {272, 89}}
-[RTUnitLayout initialLayoutAttributesForAppearingItemAtIndexPath:] : <NSIndexPath: 0xc000000000058016> {length = 2, path = 0 - 11} frame={{0, 979}, {175, 89}}
-[RTUnitCell layoutSubviews] : pre-super: {{0, 979}, {272, 89}}
-[RTUnitCell layoutSubviews] : post-super: {{0, 979}, {272, 89}}
...
-[RTUnitLayout finalizeAnimatedBoundsChange] : {{0, 1014}, {175, 375}}
__57-[RTColumnViewController processCalculatorKeypadVisible:]_block_invoke623 : completed
完成后,如果我只是轻轻滚动 UICV,它将触发重新显示,并且所有单元格都将按应有的方式显示。我只是很困惑为什么在原始动画中没有发生这种情况,什么时候应该发生。
有什么想法吗..?
【问题讨论】:
标签: layout ios8 uicollectionview uicollectionviewcell