With the last DA SDK for XCode.
I try to update a progress bar (using https://github.com/jdg/MBProgressHUD). The weird thing I found is that my calls to the UI are ignored until all the block is executed.
I’m downloading a list of giles. Lets say are 10. When the 10 files finish to download, the UI start to process (delayed) the updates. MBProgressHUD correctly do their stuff if is called in a background thread (However, I found this is call in the main thread).
I change it to use asyncrequest + delegate with the same result. I change the MBProgressHUD with UIAlertView and the screen dim but the alertview is not show at all (as if tit was behind the windows).
So, how do this kind of task?
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Sincronizando imagenes...";
[HUD show:YES];
NSDate *lastSync = [NSDate dateFromISOString:@"2012-01-01"];
[[BestSellerCloud server].srvData beginPhoto_download_list:lastSync startWithBlock:^(ROAsyncRequest *r)
{
HUD.mode = MBProgressHUDModeDeterminate; <= Don't happend instantly
// Download and write to file
for (NSString* file in files) {
if ([file length] == 0) {
continue;
}
localPath = [file lastPathComponent];
ALog(@"Descargando %@", file);
HUD.labelText = [NSString stringWithFormat:@"Descargando %@", localPath]; <= Don't happend instantly
count++;
HUD.progress = ((count * 100.0) / [files count] / 100.0); <= Don't happend instantly
}
[HUD hide:YES afterDelay:2];
}];