ios - 使用正交滚动行为的水平 uicollectionview 中的大差距

标签 ios swift uicollectionview uikit

正如标题所暗示的那样,我遇到了一个奇怪的错误(至少我没想到),我的收藏 View 中的项目有很大的差距,就像这张照片 enter image description here

我正在使用新的 compositional layout API 中的 orthogonalScrollingBehavior 这是我的代码

let itemSize = NSCollectionLayoutSize(widthDimension: .absolute(100), heightDimension: .fractionalHeight(1))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
item.contentInsets = NSDirectionalEdgeInsets(top: 8, leading: 8, bottom: 8, trailing: 8)
        
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .absolute(200))
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])
        
let section = NSCollectionLayoutSection(group: group)
section.orthogonalScrollingBehavior = .continuous
return section

我原以为它们之间的唯一差距是由 contentInsets 造成的。如果您知道答案或发生这种情况的原因,请提供帮助

最佳答案

同样的事情发生在我身上,也许这是一个错误,因为如果可见单元格宽度适合内容宽度,那么它就不会得到这个烦人的间距。试图找到解决方法。

关于ios - 使用正交滚动行为的水平 uicollectionview 中的大差距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62917519/

相关文章:

ios - Alamofire 使凭证无效

ios - Swift:每次重新加载时都会一次又一次地添加 tableview 单元格内容?

ios - 三角形 UIView - Swift

UICollectionView,UICollectionViewFlowLayout : different cells width and same defined spacing between cells

ios - ARKit -[UIView setAnimationsEnabled :] Performing any operation from a background thread on UIView or a subclass is not supported

ios - 如何在 CollectionView 中显示照片库或相机中选定的图像?画廊 View

ios - 预加载 UITableView 单元格

ios - 重新安装应用程序时如何清除通知标记计数

ios - 检测图像结束

ios - 如何根据其中的内容使 textView 大小动态变化?