• 主页
  • iOS: Swift: SDWebImage: cell.customImageView.sd_setImage(带有: imageURL)崩溃

iOS: Swift: SDWebImage: cell.customImageView.sd_setImage(带有: imageURL)崩溃

我在一个新的Swift 3项目(XCode版本8.2.1 (8C1002))中使用CocoaPods和SDWebImage (3.8.2),下面的代码在UICollectionViewController中编译得很好:

    override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
      ...
      cell.customImageView.sd_setImage(with: imageURL, completed:{
        (SDWebImageCompletionBlock) in

      })
      ...
    }

我在swift文件的顶部导入了SDWebImage。customImageView是在自定义UICollectionViewCell中定义的UIImageView

@IBOutlet weak var customImageView: UIImageView!

但是,这会在运行时崩溃,并显示以下错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView sd_setImageWithURL:completed:]: unrecognized selector sent to instance ...'

你知道为什么这段代码编译得很好,但是在运行时崩溃了吗?

转载请注明出处:http://www.jxbyjx.net/article/20230524/1108820.html