
这是cellForItemAtIndexPath ::中的代码::
let photo = self.photosArray[indexPath.row] as! AnyObjectlet photoUrlString = photo.valueForKeyPath("images.standard_resolution.url")! as! Stringprint(photoUrlString) // properly show the URL let imageVIEw = UIImageVIEw()imageVIEw.sd_setimageWithURL(NSURL(string: photoUrlString),placeholderImage: nil)print(cell.frame) // confirmed that the frame is not 0cell.contentVIEw.addSubvIEw(imageVIEw) 但是,屏幕上的单元格保持黑色.
我也通过调用cell.contentVIEw.backgroundcolor = UIcolor.redcolor()来检查它,然后它被包裹在红色屏幕中.但图像仍未显示在屏幕上.
如何在单元格上显示图像?
UPDATE
我尝试使用相同的addSubvIEw将UILabel添加到其单元格中,标签显示正确.我不确定为什么这不是图像的情况……
解决方法 看起来你的UIImageVIEw没有框架.试试这个:let imageVIEw = UIImageVIEw(frame: cell.contentVIEw.frame.bounds)总结
以上是内存溢出为你收集整理的ios – 与SDWebImage一起使用时,UICollectionViewCell保持黑色全部内容,希望文章能够帮你解决ios – 与SDWebImage一起使用时,UICollectionViewCell保持黑色所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)