如何使用Swift将图像值传递给ImageSlideshow

时间:2017-09-23 03:24:19

标签: swift slideshow sdwebimage

我正在尝试使用SDWebImage将图像放入ImageSlideshow。我可以获取图像但不能格式化它们。我希望我有意义。

let url="https://myoscapp.com/boot/json_procuct_info.php"
    Alamofire.request(url, method: .get).validate().responseJSON { response in
        switch response.result {
        case .success(let value):
          let json = JSON(value)               
          let   imageslider=json[0]["products_gallery"].array
          if json[0]["products_gallery"].array != nil {
               let imageQuantity=imageslider?.count

               var i = 0
                    while i < imageQuantity! {

            let individualimage=imageslider?[i]["image"].stringValue


                        print(individualimageUrl!)
                        i=i+1
                    }


            }

1 个答案:

答案 0 :(得分:3)

让我们尝试将SDWebImage添加到ImageSlideshow

为幻灯片显示创建插座

  

@IBOutlet var slideshow: ImageSlideshow!

使用 示例

var imageSDWebImageSrc = [SDWebImageSource]()

let url="https://myoscapp.com/boot/json_procuct_info.php"
    Alamofire.request(url, method: .get).validate().responseJSON { response in
        switch response.result {
        case .success(let value):
          let json = JSON(value)               
          let   imageslider = json[0]["products_gallery"].array
          if json[0]["products_gallery"].array != nil {
               for url in imageslider{
                   let image = SDWebImageSource(urlString: url)
                   if let sdURL = image{
                     imageSDWebImageSrc.append(sdURL)
                   }
               }
              self.slideshow.setImageInputs(self.imageSDWebImageSrc)
          }
        }
    } 

另外:

How to set ImageSlideshow image sources for ImageSource, SDWebImage, AFURLSource, AlamofireSource, KingfisherSource.