【问题标题】:Load Gif image using Kingfisher Swift cause laggy when scrolling down UITableView向下滚动 UITableView 时,使用 Kingfisher Swift 加载 Gif 图像会导致卡顿
【发布时间】:2017-03-16 22:38:31
【问题描述】:

我有一个表格视图,每个单元格都会从服务器加载 Gif 文件。 我正在使用 Kingfisher 将 Gif 文件加载到单元格 imageview 中,如下所示: cell.ivPost?.kf.setImage(with: url) Gif 已成功加载,但是向下滚动时 tableview 非常滞后。我认为加载、编码和解码 gif 文件应该使用 Kingfisher 异步完成 有人对此有解决方案吗?

我正在使用 xCode 8 和 Swift 3

【问题讨论】:

    标签: swift uitableview gif lag


    【解决方案1】:

    使用此方法

    public func setImage(with resource: Resource?, placeholder: Image? = default, options: KingfisherOptionsInfo? = default, progressBlock: Kingfisher.DownloadProgressBlock? = default, completionHandler: Kingfisher.CompletionHandler? = default) -> Kingfisher.RetrieveImageTask
    

    你可以给选项KingfisherOptionsInfo,这是一个数组 KingfisherOptionsInfoItem

    /// Decode the image in background thread before using.
    case backgroundDecode
    

    【讨论】:

      猜你喜欢
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多