Pregunta

There are some questions on Stack Overlow regarding this error, but none of the solutions seemed to work for me. Would someone be able to glance at my code and see why I am getting the following error?

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

AppDelegate.m:

#import "AppDelegate.h"
#import "ViewController.h" //import header file

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController* viewController = [sb instantiateViewControllerWithIdentifier:@"viewController"];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

@end
¿Fue útil?

Solución

You are setting the rootViewController to self.viewController but you never set self.viewController.

Try this:

self.viewController = [sb instantiateViewControllerWithIdentifier:@"viewController"];
self.window.rootViewController = self.viewController;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top