Reputation: 477
Most of my data is coming from a web service and it can take quite a bit of time. Especially on lesser networks.
The screen comes in black. I can see from NSLogs that the data is sowing down the pipe but the indicator is not showing. Then when it is sone the indicator pops up ever so briefly then disappears.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[HUD showUIBlockingIndicatorWithText:@"Fetching DATA"];
[self callDatabase];
[HUD hideUIBlockingIndicator];
}
Upvotes: 2
Views: 717
Reputation: 7102
It sounds like your [self callDatabase]
method may be blocking the main thread. When the main thread is blocked modifications to the view hierarchy will not be reflected on screen. Can you put the database work in the background? Perhaps like this:
[HUD showUIBlockingIndicatorWithText:@"Fetching DATA"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self callDatabase];
dispatch_async(dispatch_get_main_queue(), ^{
[HUD hideUIBlockingIndicator];
});
});
This would cause the callDatabase
method to run in the background, not blocking your main thread. Then when the database work has completed the HUD would be hidden on the main thread. Note that it's important to modify the view hierarchy (and generally, "do UI work") only on the main thread.
Upvotes: 2