1

我有一个要使用自定义单元格的 PFQueryTableViewController 子类 (DebateQueryViewController)。DebateQueryViewController 在情节提要中,我的自定义单元格有 .xib。我还为单元格创建了 .h 和 .m 文件,但我没有更改其中的代码,除了在 xib 文件中添加标签的出口等。

在 DebateQueryViewController.m 文件的 viewDidLoad 方法中,我有这个:

[self.tableView registerNib:[UINib nibWithNibName:@"RipDebateTableCell"
                                               bundle:[NSBundle mainBundle]]
         forCellReuseIdentifier:@"debateCell"];

我也有这两种方法:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 73;
}

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

    static NSString *CellIdentifier = @"debateCell";

    RipDebateTableCell *cell = (RipDebateTableCell * )[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    // Configure the cell
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    //[df setLocale:enUSPOSIXLocale];
    [df setTimeZone:[NSTimeZone systemTimeZone]];
    [df setDateFormat:@"MMM dd, yyyy "];
    NSString *my = [df stringFromDate:[object objectForKey:@"Date"]];
    NSLog(@"%@", my);
    tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);

    cell.titleOf.text = [object objectForKey:@"Topic"];
    cell.dateOf.text = [NSString stringWithFormat:@"Date: %@", my];
    cell.typeOf.text = @"Debate";
    cell.cellTop.image = [UIImage imageNamed:@"table-top"];
    //cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    //cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

在我尝试实现自定义单元之前,一切都运行良好,但现在应用程序每次都会在启动图像上崩溃。

4

0 回答 0