I'm building what is essentially a web app. Every piece of data has to be fetched from a web API. So, every UITableView that I show takes some amount of time to fill with data and I'm struggling to find a good way to show the user a loading screen.
Right now I'm popping up an action sheet, but that just seems a bit wrong. Ideally, I'd popup up a blank view over the tableview with "Loading..." on it, then fade it away when the data comes in, but I can't think of a way to do that in 8 places in my app without massive code duplication.
there are two options for you according to me.
For alertView You have to place a UIAlertView variable in .h file. Then place following code - when you are requesting/loading data.
av=[[UIAlertView alloc] initWithTitle:@"Loading Data" message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];ActInd=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];[ActInd startAnimating];[ActInd setFrame:CGRectMake(125, 60, 37, 37)];[av addSubview:ActInd];[av show];
Now, place following statement when you have finished your processing.
[av dismissWithClickedButtonIndex:0 animated:YES];[av release]; av=nil;
#import "MBProgressHUD.h" - import this where you want to use progress view.MBProgressHUD *mbProcess; - declare a variable in *.h file.mbProcess=[[MBProgressHUD alloc] initWithView:self.view];mbProcess.labelText=@"Loading Data";[self.view addSubview:mbProcess];[mbProcess setDelegate:self];[mbProcess show:YES];
[mbProcess hide:YES];
#pragma mark -#pragma mark MBProgressHUDDelegate methods
- (void)hudWasHidden {
// Remove HUD from screen when the HUD was hidded
[mbProcess removeFromSuperview];
[mbProcess release];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With