gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 04:33:09 27 4
gpt4 key购买 nike

我的应用程序今天早些时候启动正常,但现在我收到此错误

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

我看过其他线程说要更改我的代码,但我从未更改过任何代码来达到这一点。

委托(delegate).h

@interface halo4AppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate>{
UIWindow *window;
UITabBarController *tabBarController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;

@end

委托(delegate).m

@implementation halo4AppDelegate

@synthesize window;
@synthesize tabBarController;


#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
sleep(3);
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}


#pragma mark -
#pragma mark Memory management

- (void)dealloc {
[tabBarController release];
[window release];
[super dealloc];
}

@end

我的 FirstViewController 的 xib 是标题 FirstView.xib , ext

最佳答案

这不是错误,更像是警告。

在您的应用程序委托(delegate)中有一个名为 application:didFinishLaunchingWithOptions: 的方法,在此方法中您必须在该方法结束之前添加此行self.window.rootViewController = [Some UIViewController ]

再次强调,这不是错误,如果您有其他方法来创建此 rootViewController,则可以忽略 rootViewController。

编辑

您的方法应该如下所示:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[viewController1, viewController2];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}

关于ios - "Applications are expected to have a root view controller at the end of application launch",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11423909/

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