cod*_*g22 4 uitableview uiviewcontroller ios swift
我在viewController中有这个按钮,当我按下它时,它应该转到TableViewController.当我这样做时,应用程序崩溃并在控制台中打印此错误.谁能告诉我我做错了什么?谢谢!
由于未捕获的异常'NSInternalInconsistencyException'终止应用程序,
原因:' - [UITableViewController loadView]从故事板"Main"实例化了标识符为"UIViewController-iLh-Fe-Ezq"的视图控制器,但没有得到UITableView.
Dav*_*Liu 17
当我收到此错误时,我最初使用了类 UITableViewController的样板代码,但实际的视图控制器是一个UIViewController.
原始代码(导致错误):
请注意,这是连接到Storyboard中的UIViewController.
class MainViewController: UITableViewController {
//insert rest of code here
//note that funcs such as numberOfRowsInSection(_:) will have the override keyword
}
Run Code Online (Sandbox Code Playgroud)
工作代码(删除错误):
class MainViewController: UIViewController {
//insert code here
//you also must *remove the override keywords* for
// some of the included functions or you will get errors
}
Run Code Online (Sandbox Code Playgroud)
还要记住在视图控制器中为您的UITableView引用IBOutlet,并设置委托和数据源(在Storyboard中,您可以从UITableView按Ctrl + Drag拖动到视图控制器顶部的黄色圆圈,然后单击dataSource.重复此操作代表也是).
| 归档时间: |
|
| 查看次数: |
6131 次 |
| 最近记录: |