小编Ale*_*det的帖子

UICollectionView水平滚动

我尝试UICollectionView在屏幕上打印1,5个单元格,使用滚动条,您应该能够显示下一个单元格.但问题是,我设法显示1,5个单元格,但我无法滚动.当我将layout scrollDirection属性设置为时,我不知道为什么.Horizontal会创建一个垂直滚动.

这是布局和UICollectionView初始化:

let screenSize = UIScreen.mainScreen().bounds
let widthImage = (screenSize.width - CGFloat(8)) / 1.5
let heightImage = UIUtils.getHeightAspectRatio(widthImage)
//let sizeCollectionView: CGSize = CGSize(width: widthImage, height: heightImage)

let layout = UICollectionViewFlowLayout()
layout.itemSize = CGSize(width: widthImage, height: heightImage)

howTo = UICollectionView(frame: self.view.bounds, collectionViewLayout: layout)
howTo!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "howToCell")
howTo!.tag = 0
howTo!.delegate = self
howTo!.dataSource = self
self.view.addSubview(howTo!)
howTo!.snp_makeConstraints { (make) -> Void in
  make.top.equalTo(readMoreText.snp_bottom).offset(5)
  make.leading.equalTo(self.view).offset(5)
  make.trailing.equalTo(self.view)
  make.height.equalTo(115)
}
howTo?.backgroundColor = UIColor.whiteColor()
howTo?.contentMode = .ScaleToFill …
Run Code Online (Sandbox Code Playgroud)

horizontal-scrolling ios uicollectionview swift

2
推荐指数
1
解决办法
1万
查看次数