我想在iOS App中显示一个Web API呼叫之一的进度栏。目前仅向用户显示活动指示器,直到完成Web服务已完成,向他显示了状态进度是用户友好的。我看到了许多示例显示了使用用户定义的时间的进度栏,但与Web API呼叫时间持续时间无关。那么谁能引导我执行上述任务?
// like iam using SVProgress for uplaod an image
// for showing Progress iam getting Progress.fractionCompleted from uploadProgress
eg:-
Alamofire.upload(multipartFormData: { (multipartFormData) in
multipartFormData.append(data!, withName: "media", fileName: "media.jpeg", mimeType: "media/jpeg")
for (key, value) in parameters! {
multipartFormData.append((value as AnyObject).data(using: String.Encoding.utf8.rawValue)!, withName: key)
}
}, to:baseUrl,headers:parameters)
{ (result) in
switch result {
case .success(let upload, _, _):
upload.uploadProgress(closure: { (Progress) in
print("Upload Progress: (Progress.fractionCompleted)")
SVProgressHUD.showProgress(Float(Progress.fractionCompleted))
})
upload.responseJSON { response in
//self.delegate?.showSuccessAlert()
print(response.request) // original URL request
print(response.response) // URL response
print(response.data) // server data
print(response.result) // result of response serialization
// self.showSuccesAlert()
//self.removeImage("frame", fileExtension: "txt")
SVProgressHUD.dismiss()
// Hope its works for you..