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時,會觸發重新顯示,所有細胞將顯示爲他們應該。我只是難住爲什麼這在原始動畫期間不會發生,當它應該。
任何想法..?