Search code examples
iphoneobjective-cuiviewcontrolleruiwindow

How to change the default View Controller that is loaded when app launches?


I have an application, say 'MyApp', which by default loads the view controller 'MyAppViewController' whenever the application launches. Later, I added a new view controller 'NewViewControler' to the project.

I now want the 'NewViewController' to be my default view controller which loads when the app launches.

Please let me know what changes I need to make in my project to achieve this.


Solution

    1. Open MainWindow.xib and replace MyAppViewController with NewViewController.
    2. In your app delegate class, replace the property for MyAppViewController with one for NewViewController. Connect NewViewController to its new outlet in Interface Builder.
    3. In application:didFinishLaunchingWithOptions: add NewViewController's view to the window instead of MyAppViewController's view.