Ios UITableView自定义单元格不显示核心数据

Ios UITableView自定义单元格不显示核心数据,ios,uitableview,Ios,Uitableview,我让表格单元格正确显示数据,但随后创建了一个自定义单元格和类,这样我就可以对布局有更多的控制权…但我无法让自定义单元格显示数据..它只显示带有占位符文本的标签…我缺少什么 #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)ta

我让表格单元格正确显示数据,但随后创建了一个自定义单元格和类,这样我就可以对布局有更多的控制权…但我无法让自定义单元格显示数据..它只显示带有占位符文本的标签…我缺少什么

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.results.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"CellResults";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    // Configure the cell...

    ResultsCell *resultscell = (ResultsCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    NSManagedObject *result = [self.results objectAtIndex:indexPath.row];


    NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"MMMM dd, yyyy"];
    [dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
    NSString *eventDate = [dateFormatter stringFromDate:[self trialDate]];

    // formatting
    resultscell.labelEventDesc.numberOfLines = 0;

    //  populate the cells
    [resultscell.labelEventDesc setText:[NSString stringWithFormat:@"%@",[result valueForKey:@"eventdesc"]]];
    [resultscell.labelWeeksOut setText:[NSString stringWithFormat:@"%@",[result valueForKey:@"weeksout"]]];
    [resultscell.labelEventDate setText:[NSString stringWithFormat:@"%@",eventDate]];
    return cell;
}

您正在创建两个不同的单元格实例(
cell
resultcell
),配置一个并返回另一个。因此,您的自定义类实例从未真正用于任何用途

删除:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

并改变
返回单元格
返回结果单元格

现场!令人惊讶的是,你可以永远看一段代码,而只需要用另一双眼睛就能看到一些明显的东西。非常感谢…非常好用。