how to display progressbar during downloading video file from the server in to the iphone?

后端 未结 1 1945
抹茶落季
抹茶落季 2020-12-03 09:25

I have implemented video play functionality in iphone.In which i am downloading video file from the server and then play. But I want to display progress bar during downloadi

相关标签:
1条回答
  • 2020-12-03 09:49

    You can get the expected total file size in the following callback method of NSURLConnection's NSURLConnectionDataDelegate:

    - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
    {
       self.expectedTotalSize = response.expectedContentLength;
    }
    

    then in following callback method you can calculate how much data has been received:

    - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
    {
       self.recievedData += data.length;
    }
    

    And you can use UIProgressView to show current downloading status on the screen.

    0 讨论(0)
提交回复
热议问题