美文网首页
Kingfisher加载不出带逗号的图片url

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

作者: fishycx | 来源:发表于2019-12-18 09:53 被阅读0次

 问题说明

有的网络图片链接中有逗号, 使用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)

    }

}

相关文章

网友评论

      本文标题:Kingfisher加载不出带逗号的图片url

      本文链接:https://www.haomeiwen.com/subject/lvnenctx.html