我尝试使用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行