Bisma Saeed
Bisma Saeed

Reputation: 827

View not updating when it's properties change in custom delegate

I have an ACPDownloadView instance of AppDelegate. It's showing downloading progress. When I update it's progress value in my view controller, it works fine.

appdelegate.downloadVew=[[ACPDownloadView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
appdelegate.downloadVew.backgroundColor=[UIColor clearColor];
progressBtn= [[UIBarButtonItem alloc] initWithCustomView:appdelegate.downloadVew];
ACPIndeterminateGoogleLayer * layer = [ACPIndeterminateGoogleLayer new];
[layer updateColor:[UIColor blueColor]];
[appdelegate.downloadVew setIndeterminateLayer:layer];
[appdelegate.downloadVew setIndicatorStatus:ACPDownloadStatusRunning];
[appdelegate.downloadVew setProgress:0.0 animated:NO];

Now, I have a delegate method which called when progress updated.

 -(void)progressAddChannel:(NSProgress *)uploadProgress{

      float prog=uploadProgress.fractionCompleted;

      [appdelegate.downloadVew setProgress:prog animated:YES];
     [appdelegate.downloadVew layoutIfNeeded];
     NSLog(@"%f",prog);

}

This code executes and show correct value of progress. But that progress is not animating on appdelegate.downloadVew. Do anyone know about this behavior?

Upvotes: 1

Views: 64

Answers (1)

Jelly
Jelly

Reputation: 4532

Since you are making UI changes make sure your code runs on the main thread.

Upvotes: 1

Related Questions