你能帮我解决我的问题吗? 我有不同类型部分的集合视图:
我将选项卡作为部分,当用户按下选项卡时,我只调用 collectionView.scrollToItem(at indexPath + 1) 并且效果很好。 我的内容部分有问题。我做的就像水平旋转木马,我必须关闭它的滚动。 这是本节的代码。
fileprivate static var tabContantLayout: NSCollectionLayoutSection {
get {
let sectionBackground = NSCollectionLayoutDecorationItem.background(
elementKind: "background")
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(1))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
let groupSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1),
heightDimension: .estimated(1))
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])
let section = NSCollectionLayoutSection(group: group)
section.orthogonalScrollingBehavior = .continuous
section.decorationItems = [sectionBackground]
return section
}
}
如果我将 section.orthogonalScrollingBehavior 更改为 none
,所有项目都将一一垂直定位。
请问,如果您知道如何仅在此部分中关闭滚动?谢谢