Alex Rivera | Logout

How to set root view controller

Asked 2011-11-15T00:51:08.753
16

I set up an empty app with only an app delegate class, then subclassed a view controller class to create a xib to layout the app and make connections.

But when I tried to run the app on iOS Simulator, I got an error which read: CoinToss[6212:f803] Applications are expected to have a root view controller at the end of application launch Terminating in response to SpringBoard's termination. Program ended with exit code: 0

What do I need to do in order to create a root view controller for the app?

Thank you.

Edit
Report

1 Answer

25

in AppDelegate.m

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];



    UIViewController *viewController = // determine the initial view controller here and instantiate it with [storyboard instantiateViewControllerWithIdentifier:];

    self.window.rootViewController = viewController;//making a view to root view
    [self.window makeKeyAndVisible];

    return YES;
}
answered 2013-06-26T18:39:31.670

Your Answer