Search code examples
iosobjective-cxcodeswiftlaunch

iOS Loading view upon app launch


for my app i want the app to animate loading progress (loading local CoreData, and syncing with game center) before entering main page.

So i created a LoadingView as my rootview, in the ViewDidLoad(), after the local loading and game center loading finishes, i then push to the main view.

I'm pretty sure it's the wrong approach since i'm getting this warning: Presenting view controllers on detached view controllers is discouraged

Could you let me know what's a good practice?


Solution

  • I would suggest you create an initial root view which is very simple with a background and present your progress using a HUD. I use this one:

    https://github.com/jdg/MBProgressHUD

    When you have initialised everything, drop the HUD and replace the root view controller with a new one you load using storyboard. I would suggest you add a method to the app delegate you can call which does the switch for you.

    You are then off and running with the new root. To change the root you use the following in your app delegate instance.

    self.newController = <load with storyboard>;
    self.window.rootViewController = self.newController;
    [self.window makeKeyAndVisible];