Image downloading with progress using AlamofireImage?
是否可以使用AlamofireImage下载图像并获得有关下载进度的某种反馈,同时利用其UIImage扩展,图像过滤器和图像缓存的功能?
我知道我可以回退到普通的
谢谢!
尝试使用Swift 3.0.2:
1 2 3 4 5 6 7 8 9 10 11 12 13 | let utilityQueue = DispatchQueue.global(qos: .utility) let url ="http://kingofwallpapers.com/code/code-006.jpg" Alamofire.download(url) .downloadProgress(queue: utilityQueue) { progress in print("Download Progress: \\(progress.fractionCompleted)") } .responseData { response in print("Response is \\(response)") if let data = response.result.value { let image = UIImage(data: data) } } |
目前无法在
您愿意在使用案例中提出一个问题吗?我只想确切地知道您希望它如何工作,以及为什么您实际上需要进度报告。
在进程中使用Alamofire下载映像
通过进度下载文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | Alamofire.download(.GET,"url...", destination: destination) .progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in print(totalBytesRead) // This closure is NOT called on the main queue for performance // reasons. To update your ui, dispatch to the main queue. dispatch_async(dispatch_get_main_queue()) { print("Total bytes read on main queue: \\(totalBytesRead)") } } .response { _, _, _, error in if let error = error { print("Failed with error: \\(error)") } else { print("Downloaded file successfully") } } |