UICollectionView reloadData not functioning properly in iOS 7

后端 未结 17 1454
北荒
北荒 2020-11-27 11:18

I\'ve been updating my apps to run on iOS 7 which is going smoothly for the most part. I have noticed in more than one app that the reloadData method of a

17条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 11:52

    Here is how it worked for me in Swift 4

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    
    let cell = campaignsCollection.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! Cell
    
    cell.updateCell()
    
        // TO UPDATE CELLVIEWS ACCORDINGLY WHEN DATA CHANGES
        DispatchQueue.main.async {
            self.campaignsCollection.reloadData()
        }
    
        return cell
    }
    

提交回复
热议问题