Kingfisher加载不出带逗号的图片url

 问题说明

有的网络图片链接中有逗号, 使用kingfisher 加载不出来。

http://img3.imgtn.bdimg.com/it/u=3731532511,3143059206&fm=26&gp=0.jpg


参考1

参考2

解决方案:


let modifier = AnyModifier { request in

    var r = request

    // replace "Access-Token" with the field name you need, it's just an example

    r.setValue("APP/iOS", forHTTPHeaderField: "User-Agent")

    return r

}

let url = URL(string: <YOUR_URL>)

let iView = <YOUR_IMAGEVIEW>

iView.kf.setImage(with: url, options: [.requestModifier(modifier)]) { (image, error, type, url) in

    if error == nil && image != nil {

        // here the downloaded image is cached, now you need to set it to the imageView

        DispatchQueue.main.async {

            iView.image = image

        }

    } else {

        // handle the failure

        print(error)

    }

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容