将一个按钮添加到表视图的最后一个单元格

时间:2013-10-14 19:37:39

标签: ios

我已将两个原型单元格添加到名为FeedItemButtonItem的表格视图中。我的cellForRowAtIndexPath看起来像这样:

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

    if(indexPath.row != [feeds count] - 1)
    {
        cell = [tableView dequeueReusableCellWithIdentifier:@"FeedItem"];

        FeedItem *item = [feeds objectAtIndex:indexPath.row];

        [self configureTextForCell:cell withFeedItem:item];
        [self configureCheckmarkForCell:cell withFeedItem:item];
    }
    else
    {
        cell = [tableView dequeueReusableCellWithIdentifier:@"ButtonItem"];
    }

    return cell;
}

但我的应用程序因此错误而崩溃:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'

有人能指出我做错了吗?

0 个答案:

没有答案