作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我陷入了一些可能非常简单的修复,但我似乎无法弄清楚。所以我正在开发一个类似 Instagram 的应用程序,目前正在设置 feed,youtube 上的一个人提供了一个关于如何设置 feed 的精彩视频。因此,我已经完成了该项目的大部分内容,并将其连接到 firebase,为帖子创建了一个 nsobject,其中包含 postID 和 pathToImage 的字符串。 Firebase 设置:http://imgur.com/a/nznr6并且有一个带有几个字符串的 post 对象类。我包含该图像是因为显示了很多可能不重要的代码这是我的 CollectionView 代码:
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return posts.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! UserFeedCollectionViewCell
-> cell.myImage. downloadImage(from: String) <- does not exist, or doesn't show up.
cell.myImage.layer.cornerRadius = 12.0
cell.myImage.clipsToBounds = true
return cell
}
因此,如果您看到我无法让 downloadUrl 正常工作,而视频中的人能够通过自动完成功能完成此操作,请尽可能提供帮助。谢谢
最佳答案
例如,您可以使用 Kingfisher 来实现它。并且效果更好。 link它还会缓存您的图像。
如何使用:添加从存储到数据库项目节点的图像链接。像这样:
然后用它来呈现和缓存图像。
示例:
let imageView = UIImageView(frame: frame) // init with frame for example
imageView.kf.setImage(with: <urlForYourImageFromFireBase>) //Using kf for caching images
在您的情况下,如果 cell.myImage 是 UIImageView:
cell.myImage.kf.setImage(with: <urlForYourImageFromFireBase>) //Using kf for caching images
希望对你有帮助
关于ios - 找不到 downloadimageurl 来下载 Collection View 单元格图像的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43715270/
我陷入了一些可能非常简单的修复,但我似乎无法弄清楚。所以我正在开发一个类似 Instagram 的应用程序,目前正在设置 feed,youtube 上的一个人提供了一个关于如何设置 feed 的精彩视
我是一名优秀的程序员,十分优秀!