2015-06-20 121 views
0

我在这个问题上写了一个更多的detailed blog post,但是这里的要点。我在另一个UIViewController中嵌入了UICollectionView。当容器视图改变其边界时,集合视图也会更改其边界,这也会触发其UICollectionViewLayout重新布局。当UICV布局失效时,UICollectionViewCell无法重新布局它的子视图

除了单元格不会重新使用新框架和使用旧边界的布局以外,一切都很好。 这是来自重要方法的日志,很明显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时,会触发重新显示,所有细胞将显示为他们应该。我只是难住为什么这在原始动画期间不会发生,当它应该。

任何想法..?

回答

0

从Apple工程师手中收回。如果您有UICollectionViewLayoutAttributes的自定义子类,请不要像我那样犯一个愚蠢的错误,并返回YES表单isEqual:方法。

它必须是:在我blog post

- (BOOL)isEqual:(id)other { 
... 
return [super isEqual:other]; 
} 

更多细节。