I get the following error in my console:
Applications are expected to have a root view controller at the end of application launch
Below is my application:didFinishLaunchWithOptions
method:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Set Background Color/Pattern
self.window.backgroundColor = [UIColor blackColor];
self.tabBarController.tabBar.backgroundColor = [UIColor clearColor];
//self.window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"testbg.png"]];
// Set StatusBar Color
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
// Add the tab bar controller's current view as a subview of the window
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
In Interface Builder, the UITabBarController
's delegate is hooked up to the App Delegate.
Anyone know how to fix this issue?
Try to connect IBOutlet of tab bar controller to root view in the Interface Builder instead of
But actually I haven't seen such error before.
I had the same problem. If you're building a window-based application "from scratch" as I was, you'll need to do the following: (note, these are steps for Xcode 4.2.)
0. Make sure your application delegate conforms to the UIApplicationDelegate protocol.
For example, suppose our delegate is called MyAppDelegate. In MyAppDelegate.h, we should have something like this:
1. Specify the application delegate in main.m
For example,
2. Create a main window interface file.
To do this, right-click on your project and choose New File. From there, choose Window from the iOS -> User Interface section.
After adding the file to your project, go to the project's summary (left-click on the project; click summary.) Under iPhone/iPod Deployment Info (and the corresponding iPad section if you like) and select your new interface file in the "Main Interface" combo box.
3. Hook it all up in the interface editor
Select your interface file in the files list to bring up the interface editor.
Make sure the Utilities pane is open.
Add a new Object by dragging an Object from the Objects list in the Utilities pane to the space above of below your Window object. Select the object. Click on the Identity inspector in the Utilities pane. Change the Class to the application's delegate (MyAppDelegate, in this example.)
Bring up the connections inspector for MyAppDelegate. Connect the window outlet to the Window that already exists in the interface file.
Click on File's Owner on the left, and then click on the Identity inspector in the Utilities pane. Change the Class to
UIApplication
Bring up the connections inspector for File's Owner. Connect the delegate outlet to the MyAppDelegate object.
4. Finally, and very importantly, click on the Window object in the interface file. Open the Attributes inspector. Make sure "Visible at Launch" is checked.
That's all I had to do to get it working for me. Good luck!
If you use MTStatusBarOverlay, then you'll get this error.
MTStatusBarOverlay creates an additional window ([[UIApplication sharedApplication] windows) which doesn't have a root controller.
This doesn't seem to cause a problem.
I upgraded to iOS9 and started getting this error out of nowhere. I was able to fix it but adding the below code to
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
OrdoDei gave a correct and valuable answer. I'm adding this answer only to give an example of a
didFinishLaunchingWithOptions
method that uses his answer as well as accounting for the others’ comments regarding Navigation Controller.This occurred for me because i inadvertently commented out:
from