你好,我正在我的 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"))
}
}
但仍然显示滞后
最佳答案
使用Time Profiler检测具体问题所在的仪器。
关于ios - UICollectionView 滚动 SWIFT 滞后/缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35790493/