ios - UICollectionView 滚动 SWIFT 滞后/缓慢

标签 ios swift uicollectionview uicollectionviewcell sdwebimage

你好,我正在我的 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/

相关文章:

swift - 具有可失败初始化器的数组转换

iOS( swift ): Collection View indexPath(for: cell) is nil for non visible cell

IOS 基于页面的应用程序 : How to jump to another page

ios - 如何通过 Realm 移动平台使用 Google 登录

ios - 弹出 VC 时 Google 登录按钮不起作用

ios - 更新节标题中的文本 (UICollectionReusableView)

ios - 当有人滚动超出 UICollectionView 的顶部时,我如何调用方法?

ios - NSDirectoryEnumerator fileAttributes 为 nil

ios - NSDateFormatter格式化后错误的字符串

ios - 在表格 View 单元格中单击按钮时如何使用参数调用 View Controller