【发布时间】:2016-01-10 18:28:49
【问题描述】:
以下代码
NSMutableArray *textLabels = [[NSMutableArray alloc] initWithObjects:cell.textLabel1.text, cell.textLabel2.text, cell.textLabel3.text, cell.textLabel4.text, cell.textLabel5.text, nil];
for (int i=0; i<json.count; ++i)
{
textLabels[i] = [NSString stringWithFormat:@"#%@",[json[i] valueForKey:@"text"]]];
}
将正确的字符串值写入 textLabels 数组,但模拟器上的标签不会改变。为什么?
【问题讨论】:
-
json 是“ NSArray * ”,我是从后端获取的。
-
@luk2302 如果我写 cell.textLabel1.text = @"something"; ?
-
实际尝试更新标签文本的代码在哪里?您发布的代码仅填充字符串数组。
-
您应该将标签保存在数组中而不是文本中
-
UILabel *textLabel = (UILabel *)[cell viewWithTag:i];textLabel.text = [NSString stringWithFormat...
标签: ios objective-c arrays json