progress bar downloading image

2019-03-21 18:41发布

In my application i want to show the size of downloading image in label.like, 5 KB of 2MB .

Progress bar is used to show the image downloading and i want to show the total size of enter image description herecurrently downloading image as well as completed size of downloading(like,5 KB of 2 MB)

Anyone give me guidance to do this.

For this What should i do.please give me any sample code or tutorial for this.

Added Informations:

Already i'm using ASIHTTP Library .There are several delegate methods.In which method i want to give the code for finding the total size of the download image and progress of the downloding image.Please give me a code for findout the size of both (total size and downloaded size ) of an image.Please help me .stil i have no idea to find the size and which delegate method is used to support.

I'm really struggle in this.Please any one guide me to do this.

3条回答
放我归山
2楼-- · 2019-03-21 19:10

Here's a complete tutorial for building iPhone app downloading images from internet:

In part 2 there's the mechanics of having a progress bar, just download the sample project.

http://www.touch-code-magazine.com/update-your-iphone-app-with-new-content-part-2/

查看更多
forever°为你锁心
3楼-- · 2019-03-21 19:22

You can implement your own download progress system, or a simpler alternative that avoids reinventing the wheel would be to use the excellent ASIHTTPRequest library that provides you with a delegate method for getting the progress of a current download. It's also rather well documented: http://allseeing-i.com/ASIHTTPRequest/

查看更多
你好瞎i
4楼-- · 2019-03-21 19:24

Since you need some real code to start with, here are a few hints.

  • Drag and drop the ASIHTTPRequest package into your project.
  • Since what you want is download images from the internet, you only need to deal with one class in the ASI package, the ASIHTTPRequest class.
  • Read the ASIHTTPRequest.h file closely before you start. It has every interface you need.
  • Specifically, pay attention to these two methods, you will have to override them to get real-time download statistics.

.

- (void)request:(ASIHTTPRequest *)request incrementDownloadSizeBy:(long long)newLength;
- (void)request:(ASIHTTPRequest *)request didReceiveBytes:(long long)bytes;
查看更多
登录 后发表回答