你好我在CollectionView
动态显示两张图片。我正在使用sd_webImage
来显示图像。问题是在滚动单元格时会出现延迟。我用Google搜索并尝试了一些解决方案,但仍然没有运气。
这就是我展示图像的方式
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"))
}
}
但仍显示滞后