简体   繁体   English

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

[英]UICollectionView crash in [_UIFlowLayoutSection updateEstimatedSizeForSection] in iOS9 - Xcode7

I try to using auto-layout with UICollectionViewCell . 我尝试使用UICollectionViewCell自动布局。 Demo project runs fine on iOS8 but crash on iOS9. 演示项目在iOS8上运行良好但在iOS9上崩溃。 I try debug deeper but cannot find any reason. 我尝试深入调试,但找不到任何理由。 Xcode stop at [_UIFlowLayoutSection updateEstimatedSizeForSection] Xcode停在[_UIFlowLayoutSection updateEstimatedSizeForSection]

Any idea? 任何的想法?

I just downloaded your project. 我刚下载了你的项目。 First of all goto your storyboard and click on your label, in identifier pane change the tag value to something like 100. 首先转到您的故事板并单击您的标签,在标识符窗格中将标记值更改为100。

In your cellForItemAtIndexPath Function replace present implementation with 在您的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

Finally comment out line number 33 in your view controller class 最后在视图控制器类中注释掉第33行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM