uicollectionViewFlowLayout報錯

-23 14:00:11.408 JuheFinancialManagement[5054:140410] The behavior of the UICollectionViewFlowLayout is not defined because:2017-08-23 14:00:11.408 JuheFinancialManagement[5054:140410] the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values.2017-08-23 14:00:11.409 JuheFinancialManagement[5054:140410] The relevant UICollectionViewFlowLayout instance is, and it is attached to; layer =; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout:.

2017-08-23 14:00:11.409 JuheFinancialManagement[5054:140410] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

出錯的原因是:UICollectionViewFlowLayout的itemSize的寬或者高設置的有問題!它的size必須在父容器的范圍之內!

解決:

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{

//寬度-2就可以小于collectionView的kscreenWidth,這個時候就不會報錯

return CGSizeMake(kScreenWidth-2, 45);

}

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容