我让表格单元格正确显示数据,但随后制作了一个自定义单元格和类,以便我可以更好地控制布局......但我无法让我的自定义单元格显示数据......它只显示带有占位符文本的标签......我错过了什么?
#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;
}