chwi
chwi

Reputation: 2802

Set root controller with interface builder

When I drag a Navigation Controller on to the storyboard I get the Navigation Controller and a Table View Controller. I do not want the table view, so I delete it, insert a regular view controller, change its class to e.g LoginView, right-click and drag: "Relationship Root View Controller" from the Navigation Controller on to the View Controller.

Now when I run the application I get

Application windows are expected to have a root view controller at the end of application launch

I do not want to fix this programatically, since last time I did this it worked out of the box (xcode 4.2, now I upgraded to 4.3). Also, when adding the Navigation Controller in 4.2 it came with a View Controller, not a Table View Controller.

Navigation Controller has "Is Initial View Controller" set.

Upvotes: 4

Views: 8394

Answers (6)

invisible squirrel
invisible squirrel

Reputation: 3008

In Xcode 8:

  1. Right-click and drag from the Navigation Controller to the View Controller.
  2. Choose root view controller in the pop-up, under the section 'Relationship Segue'.

Upvotes: 7

Alexander Volkov
Alexander Volkov

Reputation: 8372

  1. Select View Controller in Interface Builder
  2. Open Attributes Inspector
  3. Set the checkbox "Initial View Controller"

Upvotes: 2

theprojectabot
theprojectabot

Reputation: 1163

The issue is in the AppDelegate.m : - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Try to comment out everything except for the return of course. When making an empty application this code is inserted for you and interferes with the initial view controller check that you did with in the root view controller on your storyboard. Also within your projects target, make sure the info.plist shows your storyboard as the mainstoryboard. Then finally make sure you have your initial view controller checked within the storyboard view. Select the view controller then look at its attributes. Check that little box.

Upvotes: 0

Cornel Damian
Cornel Damian

Reputation: 733

It's an old post, but for the ones that are still having this problem.

  • in xib you need a view controller and a window.
  • select window and go to "Connections Inspector"
  • connect rootViewController with the view controller

this should work, for me it worked.

Upvotes: 4

chwi
chwi

Reputation: 2802

My solution was to start a new project with "Single View" instead of "Empty"

Upvotes: -1

flashfabrixx
flashfabrixx

Reputation: 1183

Try doing it the other way around.

  • Delete the navigation controller
  • Select the lasting view controller, in the menu "Editor > Embed in > Navigation Controller"
  • Check if the navigation controller has "Is Initial View Controller" selected
  • Check if in the AppDelegate there is no unnecessary code put in the applicationDidFinish method (should be empty if you didn't put a custom code in it)
  • Check if your view controller contains -(void)loadView and delete the method to avoid a black screen on startup

Hope it helps.

Upvotes: 8

Related Questions