iOS some problems during download multiple images

2019-08-30 18:00发布

问题:

I have this 3 classes.

  • MyViewController.m (click to see code)
  • MySync.m (click to see code)
  • ImageDownload.m (click to see code)

When I download a image, I try to update the UIProgressView in my UIViewController, but the update are delayed, and I see a strange problem (see the blank space in attach image).

When all downloads are complete and execute the method "syncComplete" of "MyViewController", the method "dismissAlertView" is not triggered :S

I hope somebody can help me.

Thanks.

回答1:

Assuming that syncComplete is the one calling dismissAlertView, make sure iI is calling to the UI thread (main thread). Something like this if you use GCD:

dispatch_async (dispatch_get_main_queue (),  ^{
// call the dismissAlertView method here
});