滚动SWIFT时UICollectionView滞后/慢

时间:2016-03-04 07:36:11

标签: ios swift uicollectionview uicollectionviewcell sdwebimage

你好我在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"))
}
}

但仍显示滞后

1 个答案:

答案 0 :(得分:0)

使用Time Profiler工具检测确切问题的位置。