【问题标题】:SDWebImage Library getting error with swift 3 Xcode 8.0SDWebImage 库在 swift 3 Xcode 8.0 中出现错误
【发布时间】:2016-09-26 07:51:44
【问题描述】:

我的项目是用 Xcode 7 开发的,昨天我用 Xcode 8 更新了它,并将 swift 编码转换为最新的 swift 版本 swift 3.0。现在它在某个地方给了我错误,我已经解决了所有问题,但没有因为 sd_setImage(with: ,placeholderImage: ,completed) 行的模棱两可使用而获得 ID。谁能帮我解决这个问题?我正在使用SDWebimage Library 在我的应用程序中加载图像。

谢谢

已检查此链接,但不知道该怎么做。 Ambiguous use of 'sd_setImage(with:placeholderImage:completed:)' with Swift 3

【问题讨论】:

标签: ios swift3 ios10 xcode8 sdwebimage


【解决方案1】:

Swift 3 有一种解释 Obj-C 标头的新方法,似乎现在有来自 2 个 diff 类冲突的 2 个方法签名。

临时修复可能是使用 url:placeholderImage:options:completed 变体。

    view.sd_setImage(with: photoURL, placeholderImage: placeHolderImage, 
options: [.continueInBackground, .lowPriority]) { (image, error, cacheType, url) in
     ...
    }

【讨论】:

    【解决方案2】:

    嘿,我想这会解决你的问题

    YOURIMAGEVIEW.sd_setImage(with: URL(string: IMAGEURL), 
    placeholderImage: UIImage(named:"PLACEHOLDER"), options: [], completed: { 
    (image, error, cache, url) in
       DispatchQueue.main.async {
          YOURIMAGEVIEW.image = image
       }
    })
    

    来自https://stackoverflow.com/a/39024894/4720374

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-03
      • 1970-01-01
      • 1970-01-01
      • 2017-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多