overridefunclayoutAttributesForElementsInRect(rect:CGRect) -> [UICollectionViewLayoutAttributes]? {
letarray: [UICollectionViewLayoutAttributes] =super.layoutAttributesForElementsInRect(rect)!
returnnewArray
}
在程序不崩潰的情況下出現(xiàn)錯(cuò)誤日志
Logging only once for UICollectionViewFlowLayout cache mismatched frame
This is likely occurring because the flow layout subclass PhotoDemo.LJFFlowLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them
開(kāi)始很納悶,然后在這個(gè)方法中重新創(chuàng)建數(shù)組去承接上面的返回值,還是會(huì)有崩潰的日志,用這個(gè)方法可以解決
但是不知道究竟是為什么,希望有大神看見(jiàn)了可以幫忙回答下
overridefunclayoutAttributesForElementsInRect(rect:CGRect) -> [UICollectionViewLayoutAttributes]? {
letarray: [UICollectionViewLayoutAttributes] =super.layoutAttributesForElementsInRect(rect)!
//換了一個(gè)數(shù)組的初始化方法完美的解決了問(wèn)題
letnewArray:[UICollectionViewLayoutAttributes] =NSArray(array: array, copyItems:true)as! [UICollectionViewLayoutAttributes]
returnnewArray
}