我读过很多类似的帖子,但我找不到适合我的答案。我的 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。我在控制台中收到这些消息:
PatternView_iPhone xib 属于 PatternViewController 类。
在项目摘要中,我有以下设置:
和
错误表明 xib 中存在类名为 RootviewController 的对象。打开 xib/storyboard 作为源(右键单击并作为源代码打开)并搜索 RootviewController。找到标签来的地方并找到对象并将其更改为有效对象。
是的,这是一篇旧文章,但这是我针对 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">