0
我想用alamo fire下載文件並使用帶有進度的alert來顯示它,但是當alamo fire progress.fractionCompleted增加時不會移動進度我使用static VAR等於progres.fractionCompleted,但它不工作太 這裏是我的代碼在alamo fire中的進度視圖在swift中下載文件時不會更新3
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)
}
**請記住,這將工作做好,問題只是更新發展觀**
迅速不讓我跑,因爲RetunzAPIProgress –
我已經更新我的代碼,讓我知道你已經解決了應用.. –
OK忘記了這一點,我用另一種代碼但有另一個問題,請幫助我,並在此後固定我會回答這個問題,我自己在這裏是該問題的鏈接 https://stackoverflow.com/questions/46137799/why-alamo-fire-download -progress式警報,將閃爍和最落後屏-ST –