show activity indicator while loading ViewController
Posted
by
Crystal
on Stack Overflow
See other posts from Stack Overflow
or by Crystal
Published on 2012-09-24T21:36:34Z
Indexed on
2012/09/24
21:37 UTC
Read the original article
Hit count: 174
iphone
I have a ViewController that takes time to load its views. When I run Instruments, I see from the home screen, if I tap on the icon that pushes that view controller onto the stack, it's half laying out the views, and half getting the data for the views. I tried adding an activity indicator to display on the home screen over the button when the button is pressed to push the LongRunningViewController onto the stack. So I basically do this:
- (IBAction)puzzleView:(id)sender {
dispatch_async(dispatch_get_main_queue(), ^{
[self.activityIndicator startAnimating];
});
PuzzleViewController *detailViewController = [[[PuzzleViewController alloc] init] autorelease];
[self.navigationController pushViewController:detailViewController animated:YES];
[self.activityIndicator stopAnimating];
}
© Stack Overflow or respective owner