uicollectionviewのcellにsdwebimageを使って画像を挿入した時に、最後のcellしか表示されないのですが、どうすれば全てのセルの画像を表示できますか。
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { // アイテムを作成 let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) ref = Database.database().reference() ref.child("users").child(userID!).child("store").observe(DataEventType.value, with: { (snapshot) in if let snap = snapshot.value as? [String : AnyObject] { print(self.store.count) if indexPath.item < self.store.count { self.result = snap[self.store[indexPath.item]] as? String var url = URL(string:self.result!) self.imageView1.sd_setImage(with:url) cell.backgroundView = self.imageView1 self.imageView1.sd_setImage(with: url, completed: { (_, error, _, _) in if error == nil { self.imageView1.layer.masksToBounds = true self.imageView1.layer.cornerRadius = self.imageView1.frame.size.width * 0.5 } }) } } }) return cell }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/24 08:05