0

我正在尝试重新创建可以刷过的火种卡堆栈。我决定使用 UIcollectionView 来做这件事。

我打算制作一组用户对象,在每个对象中,都会有一组图像。所以对于部分的数量,我会说 arr.count 和子部分的数量 arr[section].arrImg.count。

目前,我有一个问题,当我运行项目时,我会得到一个包含 5 个图像的垂直堆栈。我假设每个图像代表一个细胞。但我需要将这些细胞像火种一样堆叠在一起。

我该怎么做(像火种一样堆叠在一起)?

制作卡片布局的逻辑:

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    print(peopleArr[section].arrOfProfileImages.count, "jfldhsajklfhsdkj")
    return peopleArr[section].arrOfProfileImages.count
}


//This current version loads all people it should only return like 3...
func numberOfSections(in collectionView: UICollectionView) -> Int {
    print("fkhdsgafhjdgsajhfgdsak", peopleArr.count)
    return peopleArr.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cardCell", for: indexPath) as! DatingCardCollectionViewCell
    cell.imageView.image = UIImage(named: "ProfileImage")//peopleArr[indexPath.row].arrOfProfileImages[indexPath.section]
    return cell
}
4

0 回答 0