gpt4 book ai didi

ios - 翠鸟框架不下载图像

转载 作者:行者123 更新时间:2023-11-29 00:55:06 25 4
gpt4 key购买 nike

我正在尝试使用 kf_setImageWithURL 设置 imageView 的图像

let url = NSURL("myurl")
someImage.kf_setImageWithURL(url, placeholderImage: nil, optionsInfo: [.Transition(ImageTransition.Fade(1))],
progressBlock:{ receivedSize, totalSize in
print("1): \(receivedSize)/\(totalSize)")
},
completionHandler: { image, error, cacheType, imageURL in
print(image)
print("1): Finished")

})

当我尝试在浏览器中打开它时,图像会正确加载。但由于某种原因,completionHandler 中的图像始终为 nil,我无法设置我的 ImageView 的图像。如果有人能指出这里出了什么问题,那就太好了。

更新

我尝试在 block 中打印错误消息并得到这个

Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo={NSUnderlyingError=0x134637690 {Error Domain=kCFErrorDomainCFNetwork Code=-1100 "(null)"}, NSErrorFailingURLStringKey=file:///http:/192.168.10.125/animapp/uploads/1458219536306null1.1458219542.jpg, NSErrorFailingURLKey=file:///http:/192.168.10.125/animapp/uploads/1458219536306null1.1458219542.jpg, NSLocalizedDescription=The requested URL was not found on this server.}

最佳答案

问题出在我设置 URL 的方式上。我是这样设置 url 的

let url = NSURL(fileURLWithPath: "myurl")

这会在网址末尾添加 -- file:/// 。当我将其更改为

时,它工作得很好
let url = NSURL(string: "myurl")

关于ios - 翠鸟框架不下载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37671291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com