2016-03-04 166 views
0

你好我動態地在我的CollectionView中顯示兩個圖像。我正在使用sd_webImage來顯示圖像。問題是滾動單元格時會出現滯後現象。我搜索了它並嘗試了一些解決方案,但仍然沒有運氣。UICollectionView滯後/滾動速度緩慢SWIFT

這是怎麼了顯示

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

,但仍表現出滯後

回答