gpt4 book ai didi

swift - iOS 9 中的 UICollectionView 布局错误

转载 作者:行者123 更新时间:2023-11-30 10:08:57 27 4
gpt4 key购买 nike

我继承了 UICollectionViewCell 并在 IOS 8.4 中绘制如下图(上图)的图形,效果很好。单元格宽度等于屏幕边界宽度。但是当我在 IOS 9 上运行时,我得到了下面的底部图像。如果我将单元格滑动到下一个,然后再滑动回来,它的效果就像上图一样。我知道这是IOS9中的布局不正确。我补充道:

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath 
indexPath: NSIndexPath) -> UICollectionViewCell {
...
cell.contentView.layoutIfNeeded()
cell.contentView.layoutSubviews()
...
}

根本没有帮助。任何帮助,谢谢!

enter image description here

enter image description here

最佳答案

cell.layoutIfNeeded() 解决了这个问题。

关于swift - iOS 9 中的 UICollectionView 布局错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34265620/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com