ios - 使用 FirebaseUI 和存储引用加载图像
<p><p>我正在尝试使用 FirebaseUI 将图像加载到 Collection View 中
<a href="https://firebase.google.com/docs/storage/ios/download-files#downloading_images_with_firebaseui" rel="noreferrer noopener nofollow">following this pattern</a> .出于某种原因,加载了默认图像,但是我在 Google 存储中引用的图像永远不会出现。当我查看引用资料时,它们似乎都是正确的,但图像仍然不会加载到 ImageView 中。这是我的 ViewController :</p>
<pre><code>class EventViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
@IBOutlet weak var postColView: UICollectionView!
var posts: = []
var event: Event!
var ref = FIRDatabase.database().reference(withPath: "post-items")
override func viewWillAppear(_ animated: Bool) {
ref.queryOrderedByKey().observe(.value, with: { snapshot in
var newItems: = []
for item in snapshot.children {
let newPost = Post(snapshot: item as! FIRDataSnapshot)
newItems.append(newPost)
}
self.posts = newItems
self.postColView.reloadData()
})
func collectionView(_ collectionView: UICollectionView,
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! PostCell
let imageView = cell.postImageView
let picRef = FIRStorage.storage().reference().child("\(posts.imagePath!).jpg")
print(picRef)
imageView?.sd_setImage(with: picRef, placeholderImage: UIImage(named: "IMG_2684"))
return cell
}
}
</code></pre>
<p>我的猜测是它与正在加载的默认图像有关,但是一旦下载了新图像, View 就不会刷新。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>Google 存储上的图片的标题中似乎没有“.jpg”,所以当我在末尾使用“.jpg”扩展名引用它时,它没有找到它。从引用中删除“.jpg”解决了我的问题。</p></p>
<p style="font-size: 20px;">关于ios - 使用 FirebaseUI 和存储引用加载图像,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/44273257/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/44273257/
</a>
</p>
页:
[1]