应用程序在启动时应该有一个根视图控制器。

9 浏览
0 Comments

应用程序在启动时应该有一个根视图控制器。

我在控制台收到以下错误:

应用程序在启动结束时应该有一个根视图控制器

以下是我的 application:didFinishLaunchWithOptions 方法:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Set Background Color/Pattern
    self.window.backgroundColor = [UIColor blackColor];
    self.tabBarController.tabBar.backgroundColor = [UIColor clearColor];
    //self.window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"testbg.png"]];
    // Set StatusBar Color
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
    // Add the tab bar controller's current view as a subview of the window
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
}

在界面构建器中,UITabBarController 的委托已连接到应用程序委托。

有人知道如何解决这个问题吗?

admin 更改状态以发布 2023年5月24日
0
0 Comments

我曾经遇到这个问题。检查一下 main.m 文件。最后一个参数应该设置为实现 UIApplicationDelegate 协议的类的名字。

retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");

0
0 Comments

在AppDelegate中替换

 [window addSubview:[someController view]];

  [self.window setRootViewController:someController];

0