简体   繁体   English

UICollectionView滚动SWIFT时滞/慢

[英]UICollectionView lag/slow in scrolling SWIFT

hello I am displaying two images in my CollectionView dynamically. 您好,我正在我的CollectionView动态显示两个图像。 I am using sd_webImage to display the images. 我正在使用sd_webImage显示图像。 The problem is there is lag coming while scrolling the cells. 问题是滚动单元时会出现延迟。 I have googled it and try some solution but still no luck. 我已经用谷歌搜索并尝试了一些解决方案,但还是没有运气。

This is how I am showing the images 这就是我显示图像的方式

        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"))

I have tried this also 我也尝试过

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"))
}
}

but still showing lag 但仍然表现出滞后

使用Time Profiler仪器检测出确切的问题出在哪里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM