【发布时间】:2011-05-06 05:27:29
【问题描述】:
我想创建自定义 UiTableViewCell,当我创建 TableView 时,它可以工作,就像在这个 example 中一样,继承自 UIViewController。但是当我创建从 UITableViewController(不是 UIViewController)继承的控制器,并在 xib 中创建 UITableViewCell,当然连接 IBOutlet 时,我得到了这个错误:
*** Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1448.89/UITableView.m:5678
2011-05-06 07:21:34.107 tabela[11424:207] * 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“UITableView 数据源必须从 tableView:cellForRowAtIndexPath 返回一个单元格:'
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { return cellOne; }
【问题讨论】:
-
一小时前有人问过这个问题:stackoverflow.com/questions/5906592/…。简短的故事是,以编程方式(而不是在 IB 中)制作您的自定义 UITableViewCell。
-
显示您的 cellForRow 代码
标签: iphone uitableview