I have a method refreshDataAction
:
- (void)refreshDataAction
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = @"Loading Data.Please Wait";
[self deletePreviousValues];
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
NSLog(@"Getting customer values");
[self getAllCustomerValues];
NSLog(@"Got customer values");
NSError *nwerror = nil;
if (![self.secondMOC save:&nwerror])
{
NSLog(@"209 Failed to save second MOC");
}
else
{
//NSLog(@"saved success");
}
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:self.view animated:YES];
});
NSLog(@"Saved");
});
NSLog(@"Dispatched");
}
So as soon as the refreshDataAction
starts i should see the HUD. But no its like waiting for 13 seconds before showing the HUD. I have no idea why it is happening like that. I tried different one like ActivityIndicator, but to no avail. Why is my app waiting 13 seconds to start the hud. On simulator its instant. I click button and i see HUD. But on the device 13 second delay. Start the hud immediately while background thread is doing some work. Please help. Spent the entire 5 hours figuring out ways to do this task.
There is my question here :UIAlertview hanging while the thread in background is loading data
I changed it to MBProgressHUD
. May be some developers who have worked with MBProgressHUD
could see this problem.
Is my main UI thread in some sort sleep mode for 13 seconds? I really dont know at this point. FYI, it's in iOS 6.0. This is an in-house iPad app. If you need more info, do ask.Thanks