gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 00:56:27 24 4
gpt4 key购买 nike

我正在尝试使用 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
}


}

最佳答案

让我们尝试将 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.

更新:您必须安装它。

pod "ImageSlideshow/SDWebImage"

运行 pod install

关于swift - 如何使用 Swift 将图像值传递给 ImageSlideshow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46375713/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com