如何修复“Interface Builder 文件中的未知类 RootViewController”ios6

问题描述 投票:0回答:2

我读过很多类似的帖子,但我找不到适合我的答案。我的 AppDelegate 中有这样的开头:

//LOAD WINDOWS

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.window makeKeyAndVisible];

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        self.initialViewController = [[InitialViewController alloc] initWithNibName:@"InitialViewController" bundle:nil];
        [self.window setRootViewController:self.initialViewController];
    } else {
        self.patternViewController = [[PatternViewController alloc] initWithNibName:@"PatternView_iPhone" bundle:nil];
        [self.window setRootViewController: self.patternViewController];

    }

    return YES;

这适用于 iPad 版本,但不适用于 iPhone。我在控制台中收到这些消息:

  1. Interface Builder 文件中存在未知类 RootViewController。
  2. 应用程序窗口预计在应用程序启动结束时有一个根视图控制器

PatternView_iPhone xib 属于 PatternViewController 类。

在项目摘要中,我有以下设置:

enter image description here

enter image description here

iphone ios6
2个回答
5
投票

错误表明 xib 中存在类名为 RootviewController 的对象。打开 xib/storyboard 作为源(右键单击并作为源代码打开)并搜索 RootviewController。找到标签来的地方并找到对象并将其更改为有效对象。


0
投票

是的,这是一篇旧文章,但这是我针对 Swiftify 项目的确切错误消息。

在 XCode 14.2 中,我在项目中搜索包含“RootViewController”的文件,并找到了 MainWindow.xib。这确实是消息的来源,因为按照上面@Lithu的建议更改源代码中的名称更改了错误消息。

在 ChatGPT 4 的帮助下,我按照搜索结果中的

RootViewController
链接进入 MainWindow.xib 的 Interface Builder 视图。在那里,我将类名称从“RootViewController”更改为其他名称(下拉列表),然后将其改回并重建。

错误消失了,文件的源视图显示 customModule 和 customModuleProvider 标签已添加到相关行:

<viewController id="8" customClass="RootViewController" customModule="myProject" customModuleProvider="target">
© www.soinside.com 2019 - 2024. All rights reserved.