gpt4 book ai didi

ios - 关于在应用程序启动结束时有 Root View Controller 的错误消息

转载 作者:行者123 更新时间:2023-11-29 02:58:49 25 4
gpt4 key购买 nike

Stack Overlow 上有一些关于此错误的问题,但似乎没有一个解决方案对我有用。有人能看一眼我的代码,看看我为什么会收到以下错误吗?

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

最佳答案

您将 rootViewController 设置为 self.viewController 但您从未设置 self.viewController

试试这个:

self.viewController = [sb instantiateViewControllerWithIdentifier:@"viewController"];
self.window.rootViewController = self.viewController;

关于ios - 关于在应用程序启动结束时有 Root View Controller 的错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23532115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com