所以这是代码。
func numberOfSections(in collectionView: UICollectionView) -> Int {
if collectionView == self.recommendedGamesCollectionView {
return 1
} else if collectionView == self.topGamesCollectionView {
return 1
}
return 0
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if collectionView == self.recommendedGamesCollectionView {
return 6
} else if collectionView == self.topGamesCollectionView {
return 6
}
return 0
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if collectionView == self.recommendedGamesCollectionView {
let cell:RecommendedCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "RecommendedCell", for: indexPath) as? RecommendedCell)!
return cell
} else if collectionView == self.topGamesCollectionView {
let cell:TopGamesCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "TopGamesCell", for: indexPath) as? TopGamesCell)!
return cell
}
return UICollectionViewCell()
}
时髦的猴子集合视图是唯一滚动的。底部的集合视图不是。在属性检查器中也启用了两个集合视图的滚动。它们也被设置为水平滚动和反弹。