UICollectionView не показывает весь контент при горизонтальной прокрутке - PullRequest
0 голосов
/ 04 июля 2018

content in CollectionView В моем случае у меня есть только один раздел, а раздел состоит из 11 элементов. Проблема в том, что я не могу прокрутить его до последних элементов. Я могу только прокрутить очень небольшое расстояние слева направо, и это дает мне отскок назад. Вот мой код:

class RecommendGameView: UIView {

   //...
    override func layoutSubviews() {
        super.layoutSubviews()
        let layout = gameCollectionView.collectionViewLayout as! UICollectionViewFlowLayout
        layout.itemSize = CGSize(width: 80, height: 90)
        gameCollectionView.alwaysBounceHorizontal = true
                gameCollectionView.register(UINib(nibName: "CollectionGameCell", bundle: nil), forCellWithReuseIdentifier: kGameCellID)
        gameCollectionView.contentInset = UIEdgeInsets(top: 0, left: kEdgeInsetMargin, bottom: 0, right: kEdgeInsetMargin)
    }
}
    extension RecommendGameView : UICollectionViewDataSource {

        func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
            return (groups?.count ?? 0)
        }

        func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
            let cell = gameCollectionView.dequeueReusableCell(withReuseIdentifier: kGameCellID, for: indexPath) as! CollectionGameCell
            cell.group = groups![indexPath.item]
            return cell
        }
    }
...