简体   繁体   中英

Xcode: Application Windows are Expected to have a Root View Controller at the end of Application Launch

I am new to Xcode and have tried to run a simple app (i can give code if needed) with the emualtor, and an although it says 'Build Successful', a Target Output says "Application Windows are Expected to have a Root View Controller at the end of Application Launch"

Is there a fix you could tell me please? Again this is the first time I've used Xcode so sorry if it's a simple mistake :)

Thanks a lot x

In you Application Delegate class in the - (void)applicationDidFinishLaunching:(UIApplication *)application method you need to set a root view controller to your window like this :

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

    UIViewController *viewController = [[UIViewController alloc] init];
    [self.window setRootViewController:viewController];

    [self.window makeKeyAndVisible];
    return YES;
}

The message should disappear after that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM