问题描述
我使用带有groupPagingCentered的正交截面进行了UICollectionViewCompositionalLayout,如下所示:
func neighborsRealitiesSection() -> NSCollectionLayoutSection {
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1),heightDimension: .fractionalHeight(1))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
let cellWidth = UIScreen.main.bounds.width / 3 + 1
let groupSize = NSCollectionLayoutSize(widthDimension: .absolute(cellWidth),heightDimension: .absolute(cellWidth))
let group = NSCollectionLayoutGroup.vertical(layoutSize: groupSize,subitems: [item])
let section = NSCollectionLayoutSection(group: group)
section.orthogonalScrollingBehavior = .groupPaging
let inset = (UIScreen.main.bounds.width - cellWidth) / 2
section.contentInsets = .init(top: 0,leading: inset,bottom: 0,trailing: inset)
return section
}
如果将contentInsets添加到该部分,则collectionView不会停止在倒数第二个单元格上滚动。它将滚动到下一个单元格。如果我对contentInsets发表评论,那没关系。
为什么会发生?有人有这个问题吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)