iOS9中的[_UIFlowLayoutSection updateEstimatedSizeForSection]中的UICollectionView崩溃 – Xcode7

前端之家收集整理的这篇文章主要介绍了iOS9中的[_UIFlowLayoutSection updateEstimatedSizeForSection]中的UICollectionView崩溃 – Xcode7前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试使用UICollectionViewCell自动布局. Demo project在iOS8上正常运行但在iOS9上崩溃.我尝试深入调试,但找不到任何理由. Xcode停在[_UIFlowLayoutSection updateEstimatedSizeForSection]

任何的想法?

解决方法

我刚下载了你的项目.首先转到您的故事板并单击您的标签,在标识符窗格中将标记值更改为100.

在您的cellForItemAtIndexPath函数中替换当前实现

let cell = collectionView.dequeueReusableCellWithReuseIdentifier(String("LabelCell"),forIndexPath: indexPath)
let str = "dsadasdadaddsfsf"
let len = Int(rand()) % str.characters.count
let label = cell.contentView.viewWithTag(100) as! UILabel;
label.text = str.substringToIndex(str.startIndex.advancedBy(len))
cell.setNeedsLayout()
cell.layoutIfNeeded()
return cell

最后在视图控制器类中注释掉第33行

猜你在找的iOS相关文章