When you say it takes time to get the data for the views, I assume that you mean that the PuzzleViewController doing something non-trivial somewhere like viewDidLoad .
So let's say it is in viewDidLoad . Then you can do this:
-(void)viewDidLoad { [self.activityIndicator startAnimating]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ {
This will mean that an expensive operation will be placed in the background thread and will not block the loading / display of the view controller.
This approach immediately displays the requested view when the user presses a button and shows the progress on this screen. I believe this is more common than showing an activity view when loading content before presenting the view. It also buys you a little more time; Your long operation can run in the background during the transition animation!
The reason your activity doesn't show how you do it is because you are doing all this in the user interface thread; using dispatch_async in the main queue from the main queue will not do anything, because your block will not work until the loop cycle completes.
source share