swift - 在内容大小之前设置 UICollectionViewCell 大小
问题描述
我有一个UICollectionView
动态单元格大小,在我对单元格内的内容设置比例宽度约束之前,它工作得很好。
现在看来,它UICollectionViewCell
的大小与内容的大小相匹配,而实际上我想要相反 - 内容的大小需要与单元格大小成比例。我想我错过了什么......
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> CGSize {
let width = self.collectionView.frame.width
let height = self.view.frame.height/2.5
return CGSize(width: width, height: height)
}
解决方案
有关信息,通过在 IB 中设置估计大小 = none 来修复
推荐阅读
- laravel - 如何使用 Laravel 验证语言和国家/地区 ID?
- gradle - 如何使用 gradletestkit 测试现有的 gradle.build?
- server - 让 A-Frame 在自己的空间上运行
- r - 如何切换字符串的第一个和最后一个元素的位置?
- scala - 运行 Scala Spark 代码以列出存储中的 blob 时出错
- php - PHP:mysqli_stmt_num_rows($stmt) 总是返回 0
- delphi - Delphi 异常错误加载远程图像
- docker - 如何在 Linux 上运行 Visual Studio 2019 生成的 dockered ASP.net 核心应用程序?SSL配置问题
- firebase - 在反应原生 Firebase 中处理组通知
- java - 从 JavaFX FXML 控制器类(ConfirmBox)关闭阶段