Application Windows Are Expected to Have a Root View Controller at the End of Application Launch - Even with All Known Issues Fixed

Application windows are expected to have a root view controller at the end of application launch - even with all known issues fixed

I ran into exactly the same thing trying to add a UITableView to a single-view app. Instead, create a default Master-Detail Application project (file->new->target->...) and see the AppDelegate's implementation of didFinishLaunchingWithOptions:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.

MDMasterViewController *masterViewController = [[MDMasterViewController alloc] initWithNibName:@"MDMasterViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}

Rather than directly setting your view controller as the window's rootViewController, you need to create a navigation controller init'ed with your view controller for initWithRootViewController, then set that nav controller as the window's rootViewController. (Notice you also have to squirrel away that nav controller in a property so it doesn't get destructed).

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

Change the following line:

[_window addSubview:[_navigationController view]];

to:

_window.rootViewController = _navigationController;

or, if you need iOS 3 compatibility:

if ([_window respondsToSelector:@selector(setRootViewController:)]) {
_window.rootViewController = _navigationController;
} else {
[_window addSubview:_navigationController.view];
}

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

I had this same problem. Check your main.m. The last argument should be set to the name of the class that implements the UIApplicationDelegate protocol.

retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");

Application windows are expected to have a root view controller at the end of application launch error when running a project with Xcode 7, iOS 9

From your error message:

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

How old is this "old" project? If it's more than a few years, do you still have:

[window addSubview:viewController.view];

You should instead replace it with:

[window setRootViewController:viewController];

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

I had this same problem. Check your main.m. The last argument should be set to the name of the class that implements the UIApplicationDelegate protocol.

retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");

applications expected to have a root view controller console

You should replace the

[window addSubview:tabBarController.view];

to

[self.window setRootViewController:tabBarController];

Maybe you built your project with 'Empty Application' and forgot to set the rootViewController in your didFinishLaunchingWithOptions (which exists in your AppDelegate.m).

However, if you build your project with 'Single View Application' or some other type, the project will set the rootViewController via xib by default (which might be a MainWindow.xib in your project).



Related Topics



Leave a reply



Submit