Show progress using SVProgressHUD in Swift

4.7k Views Asked by At

How can I show the progress of downloading using SVProgressHUD in Swift? I've implemented following code but it does not show the progress.

SVProgressHUD.show()
    Alamofire.download(
                url,
                method: .get,
                parameters: nil,
                encoding: JSONEncoding.default,
                headers: nil,
                to: destination).downloadProgress(closure: { (progress) in

                    DispatchQueue.main.async {
                        SVProgressHUD.showProgress(Float(progress.fractionCompleted))
                    }
                    print(progress.fractionCompleted)

                }).response(completionHandler: { (DefaultDownloadResponse) in

                    DispatchQueue.main.async {
                        SVProgressHUD.dismiss()
                    }
                })
2

There are 2 best solutions below

0
Balogun taofeek On

A workaround is to dismiss SVGProgress when progress reaches 100% 0r 1.0.

Also check https://github.com/SVProgressHUD/SVProgressHUD/issues/622? for more insight.

0
HemOdd On

The question is 2 months old, but I will put this here as it may help someone. If anyone has a problem with SVProgressHUD not showing progress, check your progress increment. It should be between 0 and 1 (so the minimum possible progress is 0 and the maximum is 1), otherwise, the shown image will be a completed circle which makes the impression that the progress is not changing.