获得了代码,但detailText仅显示在案例0的第一个“列”中
代码位于:cellForRowAtIndexPath
if (indexPath.row == 0) {
cell.detailTextLabel.text = @"A";
}
}
else if (indexPath.row == 1){
cell.detailTextLabel.text = @"B";
}
else if (indexPath.row == 2){
cell.detailTextLabel.text = @"C";
}
else if (indexPath.row == 3){
cell.detailTextLabel.text = @"D";
}
答案 0 :(得分:1)
有一个明显的右支撑不匹配,将您的代码更改为:
if (indexPath.row == 0) {
cell.detailTextLabel.text = @"A";
}
else if (indexPath.row == 1) {
cell.detailTextLabel.text = @"B";
...
您可以将其缩短为
cell.detailTextLabel.text = [@"ABCD" substringWithRange:NSMakeRange(indexPath.row,1)];