-2

enter image description here

Please see the attached screenshot, we need the loading in this manner while uploading image or video in IOS Swift

Can you please suggest any one Thankyou

Satya Ch
  • 71
  • 6
  • Pretty straightforward. When you upload with URLSession, the delegate tells you the progress. So just turn that into text and display it as a label. – matt Dec 23 '16 at 02:26

1 Answers1

1

So do your upload using an URLSession and create an URLSessionUploadTask, set yourself as the delegate of the session, and implement the didSendBodyData delegate method.

Full method signature:

connection(_:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:)

See this thread for more info:

NSURLSession, upload task - Get actual bytes transferred

In each call to that method, take totalBytesWritten, format it into a string, and through a call to the main thread, update your label text.

(Disclaimer: I haven't done this myself.)

Community
  • 1
  • 1
Duncan C
  • 115,063
  • 19
  • 151
  • 241