Is there any way I can show an image from web url in my already shown UIAlertController's action. The real scenario is I've presented the UIAlertController and side by side I'm fetching the images from url. But now I wanted to update the UIAlertAction after image's are downloaded, but they aren't updating.
Later If i open the UIAlertController than those images get displayed in UIAlertAction.
let alertController = UIAlertController(title: "My App", message: "Select option:", preferredStyle: .actionSheet)
for url in arrUrl {
let action = UIAlertAction(title: "url", style: .default) { (action) in
}
downloadImage(url) { (image) in
if image != nil {
action.setValue(image, forKey: "image")
}
}
alertController.addAction(action)
}
func downloadImage(_ strUrl: String, completionHandler: @escaping(_ image: UIImage?) -> ()) {
SDWebImageManager.shared().loadImage(
with: URL(string: strUrl),
options: .highPriority,
progress: nil) { (image, data, error, cacheType, isFinished, imageUrl) in
completionHandler(image)
}
}