【问题标题】:Grouped uitableview with editable rows - Apple example gives me a crash带有可编辑行的分组 uitableview - Apple 示例让我崩溃
【发布时间】:2011-02-21 13:36:37
【问题描述】:

我正在尝试创建一个带有可编辑行的分组表视图(行数是固定的)。 我找到了this Apple example,尤其是静态行内容技术部分。我实现了它,但应用程序因此错误而崩溃

*** Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1262.60.3/UITableView.m:5494
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'

我在 Apple 文档中做了所有解释:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

if (indexPath.section == 0) {
    return cell0;
}
// section 1
if (indexPath.row == 0) {
    return cell1;
}
return cell2;

}

cell0、cell1、cell2 是在 xib 中指定的单元格以及对应的 tableview。

出口和代表设置正确。

我知道很难找到错误,但欢迎提出任何建议。

【问题讨论】:

    标签: iphone uitableview xib


    【解决方案1】:

    确保 nib 已正确加载,并且 cell[012] 的值不为零。

    【讨论】:

    • 您好,您能详细说明一下吗?我应该在哪里调用 initWithNibName,为什么应该调用它 - 单元格不应该由 IB 实例化吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多