类型 'UIImageView' 的值没有成员'setImageWith'



我的代码不会编译,setImagewith请求图像加载在后台或异步。但是我有这个编译错误。类型" uiimageView"的值没有成员'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
                                }
                               }
                             }
                           }
                        }
                    }

    })

错误是不言自明的。UIImageView类没有方法setImageWith(_:)

您说" ... setImagewith请求图像加载在后台或异步。"是什么让您认为这种方法存在?

它是您试图使用的第三方扩展到UIImageView的一部分吗?您是基于别人的代码吗?

最新更新