0

In UIView I have taken one UIProgressView to show the Progress of the data downloaded from the server and to show those data I have taken an UITableView. The web service is via Polling, so which data is loading, I am loading it into an UITableView. But when user is scrolling the UITableView the ProgressBar paused its progress, but when again I am stopping my manual scroll of UITableView that time again the Progress bar is starting its progress from last paused position.

Code which I have Written:

Taken an outlet:

IBOutlet UIProgressView *pgrsVw;

When I am starting my web service call:

pgrsVw.progress = 0.0;
pgrsVw.hidden=false;
[self performSelectorOnMainThread:@selector(makeMyProgressBarMoving) withObject:nil waitUntilDone:NO];

Now to show the Progress:

- (void)makeMyProgressBarMoving
{
    float actual = [pgrsVw progress];
    if (actual < 1)
    {
        pgrsVw.progress = actual + PROGRESSOFDATA;
        [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(makeMyProgressBarMoving) userInfo:nil repeats:NO];
    }
    else
    {
        pgrsVw.progress=1.0;
        pgrsVw.hidden=true;
    }
}

Now when the data downloading is completed:

pgrsVw.progress=1.0;
Manab Kumar Mal
  • 20,788
  • 5
  • 31
  • 43

1 Answers1

1

I have just changed my timer code, Now it is working fine. That mean when data is loading in background, the progress bar is also moving when user is scrolling the tableview.

Changed code:

NSTimer *timer = [NSTimer timerWithTimeInterval:0.10 target:self selector:@selector(makeMyProgressBarMoving) userInfo:nil repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
Manab Kumar Mal
  • 20,788
  • 5
  • 31
  • 43
  • Thanks for the answer mate, All I can guess from the number of votes for this answer is that there are very less people who apply progress bar in UiTableViewCells. – Ramandeep Singh Gosal Sep 27 '17 at 11:00