iphone - 如何将 2 个对象添加到 tableview 单元格中

标签 iphone objective-c ios uitableview xcode4.3

目标新手。我正在尝试将 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/

相关文章:

iOS App 兼容所有设备版本

iphone - 使用 NSFetchedResultsController 进行分页?

ios - 当用户的手指超出屏幕时,UITableView 返回错误的 indexPath

ios - 使用 UIButton 数组检测哪个按钮被按下

android - VoIP 调用在不同的网络中不起作用(使用 PJSIP 和 Kamailio 服务器)

iphone - NSObject 没有存储在 objective-c 的 NSMutableArray 中

iphone - Facebook 给出安全警告 : Please treat the URL above as you would your password and do not share it with anyone

ios - scrollViewWillEndDragging 吸附到 View

iphone - 在4.2 SDK中打印-希望支持4.0而不会导致应用崩溃

ios - swift 4 可编码 : Common struct for all model