Reputation: 1392
I'm working on a messaging app, I wonder how to get these effects when sending a picture (is there a library for this already since it's so commonly used in most messaging apps):
Upvotes: 1
Views: 121
Reputation: 3304
To do this you just need to keep track of the total size of the image and how much as been transferred. This will depend on how you're sending the image. I was using a socket connection and I sent the image like this:
Network packet - [(int)length of packet][image data]
As soon as the first byte had arrived I knew the size of the image. Then I kept track of the amount transferred so far. I then passed this information to a MBProgressHUD which has an option to show a percentage. MBProgressHUD
Upvotes: 1