I get the following error in my console:
Applications are expected to have a root view controller at the end of application launch
Try to connect IBOutlet of tab bar controller to root view in the Interface Builder instead of
self.window.rootViewController = self.tabBarController;
But actually I haven't seen such error before.
I was able to set the initial view controller on the summary screen of xcode.
Click on the top most project name in the left hand file explorer (it should have a little blueprint icon). In the center column click on your project name under 'TARGETS', (it should have a little pencil 'A' icon next to it). Look under 'iPhone / iPod Deployment Info' and look for 'Main Interface'. You should be able to select an option from the drop down.
I came across the same issue but I was using storyboard
Assigning my storyboard
InitialViewController
to my window's rootViewController
.
In
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
...
UIStoryboard *stb = [UIStoryboard storyboardWithName:@"myStoryboard" bundle:nil];
self.window.rootViewController = [stb instantiateInitialViewController];
return YES;
}
and this solved the issue.
With my first view being MenuViewController
I added:
MenuViewController *menuViewController = [[MenuViewController alloc]init];
self.window.rootViewController = menuViewController;
on the App Delegate method:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
}
That worked.
I also had this error but unlike any of the answers previously listed mine was because i had uncommented the method 'loadView' in my newly generated controller (xcode 4.2, ios5).
//Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
It even told me that the method was for creating the view programmatically but i missed it because it looked so similar to other methods like viewDidLoad that i normally use i didn't catch it.
To solve simply remove that method if you are not programmatically creating the view hierarchy aka using nib or storyboard.
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
NSArray *windows = [[UIApplication sharedApplication] windows];
for(UIWindow *window in windows) {
if(window.rootViewController == nil){
UIViewController* vc = [[UIViewController alloc]initWithNibName:nil bundle:nil];
window.rootViewController = vc;
}
}