目标新手。我正在尝试将 2 个值放入 TableView 中。这是代码的一部分:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.font = [UIFont systemFontOfSize:14]; //Change this value to adjust size
cell.textLabel.numberOfLines = 2;
NSString *desc= @"Alight Destination =";
cell.textLabel.text = desc,[alDescArray objectAtIndex:indexPath.row];
return cell;
}
对于这一行 cell.textLabel.text = desc,[alDescArray objectAtIndex:indexPath.row];
该表仅显示 Alight Destination =
而未添加 [alDescArray objectAtIndex:indexPath.row];
我哪里做错了请帮忙
最佳答案
你应该使用
cell.textLabel.text=[NSString stringWithFormate:@"%@ %@",desc,[alDescArray objectAtIndex:indexPath.row];
或
NSString *desc=[NSString stringWithFormart: @"Alight Destination = %@",[alDescArray objectAtIndex:indexPath.row] ];
cell.textLabel.text = desc;
`
关于iphone - 如何将 2 个对象添加到 tableview 单元格中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11896376/