0

I am trying to recreate the tinder card stack which can then be swiped through. I have decided to do this using UIcollectionView.

I was going to make an array of user objects and within each, there would be an array of images. So for the number of sections, I would say arr.count and for the number of sub-sections arr[section].arrImg.count.

Currently, I have a problem where when I run the project I get a vertical stack of 5 images. I assume each image represents one cell. But I need these cells to be stacked on top of each other like tinder.

How can I do that (stacked on top of each other like tinder)?

The logic for making the card layout:

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
}
  • https://medium.com/@phillfarrugia/building-a-tinder-esque-card-interface-5afa63c6d3db – matt Nov 30 '19 at 01:57
  • @matt I have seen that before. The issue is that the auto layout is complicated with that. –  Nov 30 '19 at 02:05
  • Well you won’t achieve it with a flow layout as you are attempting to do. That is impossible. If you insist on using a collection view you would have to write a custom layout. And that is even harder. – matt Nov 30 '19 at 03:38
  • @matt ok I will see how I can make the way you mentioned work. –  Nov 30 '19 at 04:47
  • You might like to delete the question, if you've found the way forward. – matt Nov 30 '19 at 04:59
  • Maybe you can check this out https://github.com/mac-gallagher/Shuffle – Emre Değirmenci Nov 30 '19 at 09:31

0 Answers0