在尝试呈现 UIViewController(而不是 UITableViewController)时如何避免使用 [UITableViewController loadView]

How do I avoid using the [UITableViewController loadView] when trying to present a UIViewController (and not a UITableViewController)

我正在制作一个 iPad 应用程序,其中包含一个用于设置选项的视图。 这个 "Options" 视图有两个容器视图,每个容器视图都包含一个 TableView,其中有两种不同的选项,并且可以切换以打开或关闭这些选项。 问题是,当我尝试从主 ViewController 中创建一个按钮来打开选项视图时,出现以下错误:

Screenshot of signal SIGABRT error

在输出中这样:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "UIViewController-c2d-Su-6Id" from storyboard "Options", but didn't get a UITableView.'

我不知道为什么要使用底层函数 [UITableViewController loadView],因为我不希望我的选项视图是 TableView - 表在容器视图中。

我正在使用不同的情节提要和情节提要引用的转接,以模态方式呈现选项视图。我尝试删除按钮、转场和故事板引用,用新的替换它们,并重命名我的 ViewController.swift 文件,以及所有对它的引用,但没有成功

我也试过在网站上寻找其他解决方案,但我没有运气,我开始担心这可能是因为 containerViews 中的 tableViews...

我对学习 swift 和 Xcode 很陌生,所以请让您的解释简单易懂,并假设我完全无能:-)

我猜你可能添加了一个容器视图,它会自动将一个 "child" 视图控制器放置到 Storyboard 上,然后简单地将那个子 VC 的 Class 更改为UITableViewController --- 正如您发现的那样,这是行不通的。

要将 table 视图控制器用作子视图控制器,请添加您的容器视图,然后将普通 UITableViewController 添加到 Storyboard。然后,按住 Ctrl 键从容器视图拖动到新的 table 视图控制器,然后从弹出菜单中拖动 select Embed