I get the following error in my console:
Applications are expected to have a root view controller at the end of application launch
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.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
// Instantiate the main menu view controller (UITableView with menu items).
// Pass that view controller to the nav controller as the root of the nav stack.
// This nav stack drives our *entire* app.
UIViewController *viewController = [[XMMainMenuTableViewController alloc] init];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
// Instantiate the app's window. Then get the nav controller's view into that window, and onto the screen.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// [self.window addSubview:self.navigationController.view];
// The disabled line above was replaced by line below. Fixed Apple's complaint in log: Application windows are expected to have a root view controller at the end of application launch
[self.window setRootViewController:self.navigationController];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}