简体   繁体   中英

Value of type 'UIImageView' has no member 'setImageWith'

My code won't Compile, setImageWith requests the image to load in the background, or asynchronously. But i am having this compiling error. Value of type 'UIImageView' has no member 'setImageWith'

manager.get("https://api.flickr.com/services/rest/",
                parameters: searchParameters,
                progress: nil,
                success: { (operation: URLSessionDataTask, responseObject:Any?) in
                    if let responseObject = responseObject as? [String: AnyObject] {
                        print("Response: " + (responseObject as AnyObject).description)
                       if let photos = responseObject["photos"] as? [String: AnyObject] {
                        if let photoArray = photos["photo"] as? [[String: AnyObject]]{
                            self.scrollView.contentSize = CGSize(width: 320, height: 320 * CGFloat(photoArray.count))
                            for (i,photoDictionary) in photoArray.enumerated() {                             //1
                            if let imageURLString = photoDictionary["url_m"] as? String {               //2
                                let imageView = UIImageView(frame: CGRect(x:0, y:320*CGFloat(i), width:320, height:320))     //#1
                                if let url = URL(string: imageURLString) {
                                    imageView.setImageWith(url)                                             //#2
                                    self.scrollView.addSubview(imageView)
                                                                 //6
                                }
                               }
                             }
                           }
                        }
                    }


    })

The error is pretty self-explanatory. The UIImageView class does not have a method setImageWith(_:) .

You say "...setImageWith requests the image to load in the background, or asynchronously." What makes you think such a method exists?

Is it part of some third party extension to UIImageView that your'e trying to use or something? Are you basing this on somebody else's code?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM