【发布时间】:2016-03-04 07:36:10
【问题描述】:
您好,我正在我的CollectionView 中动态显示两个图像。我正在使用sd_webImage 来显示图像。问题是滚动单元格时会出现延迟。我已经用谷歌搜索并尝试了一些解决方案,但仍然没有运气。
这就是我显示图像的方式
cell.profileImageView.sd_setImageWithURL(UIImage().absoluteURL(profileImageUrl), placeholderImage: UIImage.init(named: "placeholder_profile_image"))
cell.productImageView.sd_setImageWithURL(UIImage().absoluteURL(productImageUrl), placeholderImage: UIImage.init(named: "placeholder_product_image"))
我也试过了
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)) {
let profileImageUrl = (((self.dict["\(indexPath.section)"] as?NSDictionary)!["User"] as?NSDictionary)!["profile_image"] as?NSString)
let productImageUrl = (((self.dict["\(indexPath.item)"] as?NSDictionary)!["Trip"] as?NSDictionary)!["product_image_path"] as?NSString)! as String
dispatch_async(dispatch_get_main_queue()) {
cell.profileImageView.sd_setImageWithURL(UIImage().absoluteURL(profileImageUrl), placeholderImage: UIImage.init(named: "placeholder_profile_image"))
cell.productImageView.sd_setImageWithURL(UIImage().absoluteURL(productImageUrl), placeholderImage: UIImage.init(named: "placeholder_product_image"))
}
}
但仍然显示滞后
【问题讨论】:
标签: ios swift uicollectionview uicollectionviewcell sdwebimage