gpt4 book ai didi

ios - 完整图像未加载到 UICollectionView Cell Swift 4 内的 ImageView 上

转载 作者:行者123 更新时间:2023-11-29 06:02:59 24 4
gpt4 key购买 nike

我使用自动调整大小来为所有设备制作适当的图像大小。在 UICollectionView 单元格内放置一个 UIView。在 UIView 上,我放置了一个具有相同 View 宽度的 ImageView 和另一个具有一些内容的 View 。现在我对所有设备使用自动调整大小,但 iPhone 6s Plus 和 iPad 的图像大小有所不同。我更改了所有内容模式,但它保持不变。下面给出了我的 CollectionViewLayout 代码。

     func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> CGSize {

if collectionView == collection || collectionView == collection_favourite{


return CGSize(width: display_width / 2, height: 290)

}

}

当我使用调试 View 层次结构时,我的 ImageView 似乎完全按照我想要的方式调整了大小(如下图所示,带有蓝色阴影的是我的 imageView),但是其上显示的图像发生了偏转,或者没有正确显示。我没有知道如何处理它,我做了很多更改但没有解决。请帮忙解决这个问题。提前致谢

enter image description here

这是我的 Storyboard的屏幕截图

enter image description here

在此处输入图像描述

enter image description here

enter image description here

enter image description here

最佳答案

UIImageview 的内容模式是什么?您是否在 cellForItemAtIndexPath 中调用layoutIfNeeded?

关于ios - 完整图像未加载到 UICollectionView Cell Swift 4 内的 ImageView 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51373229/

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