Swift Dropbox进度条

时间:2015-10-18 13:59:42

标签: swift dropbox-api

我正在开发一个将图像上传到Dropbox客户端的快速应用 up lode过程工作正常我只想显示上传的进度

谢谢你的帮助

  func uplodeimage(filePath : String , fileData : NSData)
{

        let client = Dropbox.authorizedClient ;

        client?.filesUpload(path: filePath, body: fileData).progress({ (bytesWritten : Int64, totalBytesWritten : Int64, totalBytesExpectedToWrite : Int64) -> Void in


        let uplodProgress : Float  = Float(totalBytesWritten) / Float(totalBytesExpectedToWrite) as Float;


 dispatch_async(dispatch_get_main_queue(), { () -> Void in

    self.progressbar.progress = uplodProgress
    self.progressLabil.text = "\(uplodProgress * 100)%"
    self.loadingIndicator.stopAnimating();
    self.loadingIndicator.removeFromSuperview();
    self.loginBtn.enabled = true ;
    self.uplodBtn.enabled = true;

            });




        });


}

不是客户端上传进度是一个保管箱功能

1 个答案:

答案 0 :(得分:0)

你可以试试这个:

dispatch_async(dispatch_get_main_queue(), { () -> Void in
    self.progressBar.setProgress(Float(totalBytesWritten)/Float(totalBytesExpected), animated: true)
});