Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用UICollectionView Yalantis/Koloda时,初始卡相同_Ios_Uicollectionview_Koloda - Fatal编程技术网

Ios 使用UICollectionView Yalantis/Koloda时,初始卡相同

Ios 使用UICollectionView Yalantis/Koloda时,初始卡相同,ios,uicollectionview,koloda,Ios,Uicollectionview,Koloda,我正在使用这个库,我能够将我的数据从Firebase显示到卡上。但是,初始卡片(3个默认)都是相同的。然后,一旦我滑动它们,我就可以看到下一个结果。只有当我在卡片上显示CollectionView而不是UIView时,才会出现这种情况 以下是我获取数据的方法: var person: Person! func fetchUser() { let databaseRef = Database.database().reference(withPath: "users") dat

我正在使用这个库,我能够将我的数据从Firebase显示到卡上。但是,初始卡片(3个默认)都是相同的。然后,一旦我滑动它们,我就可以看到下一个结果。只有当我在卡片上显示CollectionView而不是UIView时,才会出现这种情况

以下是我获取数据的方法:

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()

    })
}
以下是我如何将数据分配给单元格:

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
是一个处理
Person
对象的单例程序,具有
append()
removeAll()
功能

下面是我的结果:


有没有人能让它在tableView或collectionView中正常工作?

确保koloda中的索引(koloda:KolodaView,viewForCardAt index:Int)有效。似乎您对所有图像都使用了一个索引。

请确保koloda中的索引(koloda:KolodaView,viewForCardAt index:Int)有效。似乎您对所有图像都使用了一个索引