道歉,如果这是作为初学者的问题。我正在尝试使用节和自定义单元格格式填充UITableView。
我调试了这段代码,每个标签上的标签都返回正确的值:
-(UITableViewCell *)cellForIndexPath:(NSIndexPath *)indexPath forData:(NSObject *)cellData {
static NSString *CellIdentifier = @"MatterWIPCell";
RVMatterWIPExceptionSummary *matterWIPSummary = (RVMatterWIPExceptionSummary *)cellData;
UITableViewCell *cell = [self.searchableTable dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
UILabel *label;
label = (UILabel *)[cell viewWithTag:1];
label.text = [[DataFormat dataFormat] stringLabelFormat: matterWIPSummary.fileNumber];
label = (UILabel *)[cell viewWithTag:2];
label.text = [[DataFormat dataFormat] stringLabelFormat: matterWIPSummary.clientName];
label = (UILabel *)[cell viewWithTag:3];
label.text = [[DataFormat dataFormat] stringLabelFormat: matterWIPSummary.matterTitle];
label = (UILabel *)[cell viewWithTag:4];
label.text = [[DataFormat dataFormat] currencyFormat:matterWIPSummary.workInProgress withDecimals:YES];
label = (UILabel *)[cell viewWithTag:5];
label.text = [[DataFormat dataFormat] stringLabelFormat:matterWIPSummary.matterDescription];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
return cell;
}
我已经检查了它使用相同单元格标识符的故事板。
我是否遗漏了某些东西,所以即使单元格永远不会返回nil,数据也不会显示?
谢谢
答案 0 :(得分:-1)
添加[cell.contentView addSubview:label];返回小区之前;当然用类似这样的东西声明标签UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(10,0,320,25)];