我有一个来自webservice的图片网址["http://1.jpg", "http://2.jpg", "http://3.jpg", "http://4.jpg"]
。现在我想展示具有扩展INSPhotoGallery INSPhotoGallery
这很好的工作:
lazy var photos: [INSPhotoViewable] = {
return [
INSPhoto(imageURL: URL(string: "http://1.jpg"), thumbnailImage: UIImage(named: "thumbnailImage")!),
INSPhoto(imageURL: URL(string: "http://2.jpg"), thumbnailImage: UIImage(named: "thumbnailImage")!),
INSPhoto(imageURL: URL(string: "http://3.jpg"), thumbnailImageURL: URL(string: "thumbnailImage")),
INSPhoto(imageURL: URL(string: "http://4.jpg"), thumbnailImageURL: URL(string: "thumbnailImage")),
INSPhoto(imageURL: URL(string: "http://5.jpg"), thumbnailImageURL: URL(string: "thumbnailImage"))
]
}()
但我无法动态返回图像。如果我从Web服务获得10或100张图像该怎么办。如何显示,请帮助我。
答案 0 :(得分:0)
您可以使用这样的地图
let imgUrlArr = ["http://1.jpg", "http://2.jpg", "http://3.jpg", "http://4.jpg"]
var photos: [INSPhotoViewable] = imgUrlArr.map { INSPhoto(imageURL: URL(string: $0), thumbnailImage: UIImage(named: "thumbnailImage")!) }