How to change the standard view manager that loads when the application starts?

I have an application, for example, “MyApp”, which by default loads the view controller “MyAppViewController” whenever the application starts. Later, I added a new view controller, NewViewControler, to the project.

Now I want the "NewViewController" to be my default view controller, which loads when the application starts.

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

+6
objective-c iphone uiviewcontroller uiwindow
source share
4 answers
  • Open MainWindow.xib and replace MyAppViewController with NewViewController.
  • In the application delegation class, replace the MyAppViewController property with one for NewViewController. Plug the NewViewController into its new outlet in Interface Builder.
  • In application:didFinishLaunchingWithOptions: add the NewViewController view to the window instead of the MyAppViewController view.
+7
source share

Easy, simple:

  • Open storyboard
  • Click on the view controller corresponding to the view you want to be the initial view.
  • Open Attribute Inspector
  • Check the box next to “View controller” in the “Controller view” section.
+15
source share

Most likely your main NIB file is still set to "MainWindow", check the * -Info.plist file.

If this is the case, you can open MainWindow.xib in Interface Builder. You should see the View Controller element. Lift up the inspector window and change the class identifier to point to the new class. This should take care of instantiating your class.

As it seems like a "newbie" (please forgive me if I am wrong). I also highly recommend the following article:

IPhone Programming Basics: Understanding View Controllers

Helped me understand the whole thing of ViewController and the interaction with IB.

+2
source share

As for me with xcode 4.3.3, all I had to do was just replace all the links “MyAppViewController” with “NewViewController” in the h and m files of AppDelegate.

Perhaps all the other steps were taken in new versions of xcode.

Hope this helps.

0
source share

All Articles