我有一个表格,我想用自定义 tableViewCells 填充它,以便为用户提供有关订单的信息。问题是表格视图显示了单元格,但没有用我需要的信息填充它们。当我插入断点时,我发现无论我做什么,单元格都是空的。这是我的 cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
OrderOverViewCell *cell = (OrderOverViewCell *)[tableView dequeueReusableCellWithIdentifier: @"orderOverviewCell"];
OrderClass *orderClass = nil;
if (filteredArray == nil) {
if (sortedArray.count >0) {
orderClass = sortedArray[indexPath.row];
}
}
else if (filteredArray != nil) {
orderClass = filteredArray[indexPath.row];
}
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd/MM/yyyy HH:mm"];
NSString *orderDate = [dateFormatter stringFromDate:orderClass.orderDate];
cell.orderTitle.text = [NSString stringWithFormat:@"%@%@ %@",orderClass.companyName,@",", orderDate];
cell.orderDetail.text = [NSString stringWithFormat:@"%@ %@ %@ %@.", @"order nummer:",orderClass.orderNumber, @"betaling:", orderClass.orderPaymentType];
if ([orderClass.orderDelivery isEqualToString:@"Bezorgen"]) {
cell.orderDelivery.text = [NSString stringWithFormat:@"Levering: Bezorgen op %@, %@, %@", orderClass.orderAdress, orderClass.orderAdressZip, orderClass.orderCity];
}
if ([orderClass.orderDelivery isEqualToString:@"Afhalen"]) {
cell.orderDelivery.text = [NSString stringWithFormat:@"Levering: Afhalen op ingestelde datum en tijd."];
}
cell.orderIndication.image = nil;
if ([orderClass.preparing isEqualToString:@"1"]) {
if ([orderClass.ready isEqualToString:@"1"] ){
if ([orderClass.delivered isEqualToString:@"1"]){
cell.orderIndication.image = [UIImage imageNamed:@"order_3.png"];
}
else {
cell.orderIndication.image = [UIImage imageNamed:@"order_2.png"];
}
}
else {
cell.orderIndication.image = [UIImage imageNamed:@"order_1.png"];
}
}
cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"orderCellBG.png"]];
return cell;
}
有人知道我做错了什么吗?任何帮助将不胜感激。