[使用SDWebImage时的UICollectionView错误

问题描述 投票:0回答:1

我使用SDWebImage和cell.Food.sd_setImage(with:URL(string:foodImage [indexPath.row]))显示图像,foodImage数组包含URL。我运行它,并在下面遇到另一个错误。我不知道如何解决它,也找不到任何错误。有谁知道如何修理它?谢谢。

Task <D58DD2B3-88A0-4673-BF27-A7AC5A65F3B4>.<3> finished with error - code: -999
...
Task <340CEBFF-ADE8-4C07-851D-0BD1F0159F20>.<8> finished with error - code: -999
Failed to get TCPIOConnection in addInputHandler
Task <5C16CD7B-2234-4BB6-BE2A-0D71ECD35658>.<12> finished with error - code: -999
[] nw_endpoint_flow_attach_protocols_block_invoke [4.1 107.20.173.119:443 in_progress socket-flow(satisfied)] Failed to attach application protocol CFNetworkConnection
arrays swift uicollectionview swift4 sdwebimage
1个回答
0
投票

我正在使用sd_WebImage,它对我有用,其代码如下:-

  import SDWebImage

  func collectionView(_ collectionView: UICollectionView, cellForItemAt 
     indexPath: IndexPath) -> UICollectionViewCell {

    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", 
        for: indexPath) as! stackCollectionViewCell

     cell.imageview.sd_setImage(with: URL(string: imageArr[indexPath.row]), 
     placeholderImage: UIImage(named: "image"))


    return cell
  }

但是您的错误是针对Thread的,因为某些东西打断了主线程,这就是出现此错误的原因。这样您就可以共享您的代码了。

谢谢

© www.soinside.com 2019 - 2024. All rights reserved.