iosswifturlkingfisher

Can't display image from url using Kingfisher


I imported Kingfisher

 import UIKit
 import Kingfisher
    

This is my simple code to can explain the problem
Creating an imageView and trying display image from 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)

       
    }


}

Solution

  • Please check your url again as I've tried another url and it works fine, you can check it:

    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)
    
               
            }
    
    }
    

    or you can make url like this if it helped:

     let rawstring = "https://apis.baytelhekma.com/zinzo/public/storage/products/November2020/eUWwRjNCYCdHUjGIQiJk.png"