0
#import <UIKit/UIKit.h>

@interface FourthViewController : UIViewController{

//@interface FourthViewController : UITableViewController{

我想更新我的表格视图,所以我尝试使用[self.tableView reloadData],但我什至无法输入这行代码,因为我在 a 中工作,UIViewController并且该tableView属性仅适用于UITableViewController's。所以我试图变得聪明,只是将其更改UIViewControllerUITableViewController但我得到了这个错误:

 Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "b4k-XH-Uhj-view-V2h-dE-ixJ" nib but didn't get a UITableView.'

我觉得这很奇怪,因为 UITableViewController 可以为 tableView 工作,但反过来不行,但是接缝就像我弄错了,或者这里发生了什么?如果您需要更多代码 =) 提前谢谢。

4

1 回答 1

0

UITableViewController 实际上只是一个 UIViewController,它包含一个到 UITableView 的出口并实现了两个 tableview 委托:UITableViewDelegate 和 UITableViewDataSource。

您可能需要考虑将 nib 文件中的 viewcontroller 实例替换为 UITableViewController 而不是标准的 UIViewController。

或者,您可以手动调整 ForthViewController 实例,方法是为包含的 UITableView 创建一个 outlet 以将 tableview 作为属性公开。

但是,如果您这样做,您还必须在某处(可能在 ForthViewController 中)手动实现两个 tableview 委托 UITableViewDelegate 和 UITableViewDataSource,并手动将 UITableView 与这些委托关联。

于 2012-04-26T13:31:20.427 回答