我正在尝试使collectionview水平滚动,
如果我将滚动方向更改为.vertical,它可以很好地滚动,但是我不知道为什么我不能水平进行此工作。如果缩小单元格的大小,可以看到创建了多个单元格,但仍然无法移动它。当我尝试滚动horizontalscrollindicator时,该单元格或项目是响应式的。有什么想法吗?
这是我用来设置布局的代码:
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .horizontal
layout.minimumInteritemSpacing = 12
layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
cv.translatesAutoresizingMaskIntoConstraints = false
cv.isUserInteractionEnabled = true
cv.backgroundColor = .green
cv.clipsToBounds = false
cv.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
cv.register(detailViewCollectionCell.self, forCellWithReuseIdentifier: "detailViewCollectionCell")
return cv
}()```