无法使用 Kingfisher 显示来自 url 的图像
Can't display image from url using Kingfisher
我导入了 Kingfisher
import UIKit
import Kingfisher
这是我可以解释问题的简单代码
创建一个 imageView 并尝试显示来自 URL
的图像
class ViewController: UIViewController {
@IBOutlet weak var image:UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
let rawstring = "https://apis.baytelhekma.com/zinzo/public/storage/" + #"products\November2020\eUWwRjNCYCdHUjGIQiJk.png"#
let url = URL(string: rawstring)
image.kf.setImage(with: url)
}
}
请再次检查您的 url,因为我已经尝试了另一个 url,它工作正常,您可以检查一下:
import UIKit
import Kingfisher
class ViewController: UIViewController {
@IBOutlet weak var image:UIImageView!
let rawstring = "https://i.insider.com/5e820b04671de06758588fb8?width=700&format=jpeg&auto=webp"
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: rawstring)
image.kf.setImage(with: url)
}
}
或者如果有帮助,你可以像这样url:
let rawstring = "https://apis.baytelhekma.com/zinzo/public/storage/products/November2020/eUWwRjNCYCdHUjGIQiJk.png"
问题不正确 url,您在地址中使用 \
。
所以
let rawstring = "https://apis.baytelhekma.com/zinzo/public/storage/" + #"products\November2020\eUWwRjNCYCdHUjGIQiJk.png"
提供
https://apis.baytelhekma.com/zinzo/public/storage/products\November2020\eUWwRjNCYCdHUjGIQiJk.png
不正确url
改成
let rawstring = "https://apis.baytelhekma.com/zinzo/public/storage/" + #"products/November2020/eUWwRjNCYCdHUjGIQiJk.png"#
或者干脆
let rawString = "https://apis.baytelhekma.com/zinzo/public/storage/products/November2020/eUWwRjNCYCdHUjGIQiJk.png"
将解决您的问题
我导入了 Kingfisher
import UIKit
import Kingfisher
这是我可以解释问题的简单代码
创建一个 imageView 并尝试显示来自 URL
class ViewController: UIViewController {
@IBOutlet weak var image:UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
let rawstring = "https://apis.baytelhekma.com/zinzo/public/storage/" + #"products\November2020\eUWwRjNCYCdHUjGIQiJk.png"#
let url = URL(string: rawstring)
image.kf.setImage(with: url)
}
}
请再次检查您的 url,因为我已经尝试了另一个 url,它工作正常,您可以检查一下:
import UIKit
import Kingfisher
class ViewController: UIViewController {
@IBOutlet weak var image:UIImageView!
let rawstring = "https://i.insider.com/5e820b04671de06758588fb8?width=700&format=jpeg&auto=webp"
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: rawstring)
image.kf.setImage(with: url)
}
}
或者如果有帮助,你可以像这样url:
let rawstring = "https://apis.baytelhekma.com/zinzo/public/storage/products/November2020/eUWwRjNCYCdHUjGIQiJk.png"
问题不正确 url,您在地址中使用 \
。
所以
let rawstring = "https://apis.baytelhekma.com/zinzo/public/storage/" + #"products\November2020\eUWwRjNCYCdHUjGIQiJk.png"
提供
https://apis.baytelhekma.com/zinzo/public/storage/products\November2020\eUWwRjNCYCdHUjGIQiJk.png
不正确url
改成
let rawstring = "https://apis.baytelhekma.com/zinzo/public/storage/" + #"products/November2020/eUWwRjNCYCdHUjGIQiJk.png"#
或者干脆
let rawString = "https://apis.baytelhekma.com/zinzo/public/storage/products/November2020/eUWwRjNCYCdHUjGIQiJk.png"
将解决您的问题