我想向我的 UITableView 单元格(我在其中显示大陆、国家和其他数据)添加一些字幕。已经用各大洲填充了我的第一张 table 。现在我想在每个大陆单元格中添加一些国家作为副标题。我补充说:
int numberEurope;
numberEurope = [europe count]; //this works fine
int numberAfrica;
numberAfrica = [africa count]; //this works fine
NSNumber *myNum1 = [NSNumber numberWithInt:numberEurope];
NSNumber *myNum2 = [NSNumber numberWithInt:numberAfrica];
NSArray *myArray = [NSArray arrayWithObjects: myNum1, myNum2, nil];
cell.textLabel.text = ContinentName;
cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"%@ countries", myArray];
return cell;
但是每个单元格中的字幕都是相同的,完整的数组显示为:( 2, 2) countries 而不是第一个单元格中的 2 个国家和第二个单元格中的 2 个国家。我究竟做错了什么?我使用的 plist 是此处的屏幕截图:Cannot Feed UITableView with .plist
最佳答案
您必须根据 indexPath 选择合适的值:
cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"%d countries", [[myArray objectAtIndex:[indexPath row]] intValue]];
关于ios - 来自 plist 数据的 UITableView 单元格字幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20378537/