I'm using this library and I am able to display my data from Firebase on to the cards. However the initial cards (3 default) are all the same. Then once I swipe them I can see the next results. This seems to be only the case when I am displaying a CollectionView on the card instead of just a UIView.
Here is how I fetch data:
var person: Person!
func fetchUser() {
let databaseRef = Database.database().reference(withPath: "users")
databaseRef.observeSingleEvent(of: DataEventType.value, with: { (snapshot) in
for child in snapshot.children {
guard let snapshot = child as? DataSnapshot else { continue }
let person = Person(from: snapshot)
self.person = person
PersonManager.shared.addPerson(person)
}
self.kolodaView.reloadData()
})
}
Here is how I assign the data to the cell:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! CustomCell
let person = PersonManager.shared.persons[indexPath.row]
cell.nameLabel.text = person.firstName
return cell
}
PersonManager
is a singleton that handles the Person
object and has the append()
and removeAll()
function.
And here is my result:
Has anyone got it to work properly with a tableView or collectionView?