【发布时间】:2017-09-06 08:39:03
【问题描述】:
我想下载一个带有 alamo fire 的文件并使用带有进度的警报来显示它,但是当 alamo fire progress.fractionCompleted 增加时进度不会移动我使用静态 var 等于 progres.fractionCompleted 但它也不起作用 这是我的代码
let destination = DownloadRequest.suggestedDownloadDestination()
Alamofire.download("example.com", to: destination).downloadProgress(queue: DispatchQueue.global(qos: .utility)) { (progress) in
print("Progress: \(progress.fractionCompleted)")
sixthLevelViewController.progressdownload = Float(progress.fractionCompleted)
DispatchQueue.main.async {
let alertController = UIAlertController(title: "Downloading", message: "please wait", preferredStyle: .alert)
let progressDownload : UIProgressView = UIProgressView(progressViewStyle: .default)
progressDownload.setProgress(ViewController.progressdownload, animated: true)
progressDownload.frame = CGRect(x: 10, y: 70, width: 250, height: 0)
alertController.view.addSubview(progressDownload)
self.present(alertController, animated: true, completion: nil)
}
} .validate().responseData { ( response ) in
print(response.destinationURL!.lastPathComponent)
}
**请记住,这会很好,问题只是更新进度视图**
【问题讨论】:
标签: swift3 download alamofire uialertcontroller uiprogressview