【发布时间】:2012-05-09 17:28:12
【问题描述】:
我正在使用主从应用程序模板。我硬编码了一个 NSArray 来设置文本标签:
groups = [[NSArray alloc] initWithObjects:@"Group1", @"Group2", nil];
然后我创建了两个数组,每个数组包含五个单词,并将这两个数组放入另一个数组中:
group1 = [[NSArray alloc] initWithObjects:@"A", @"and", @"find", @"go", @"have", nil];
group2 = [[NSArray alloc] initWithObjects:@"here", @"jump", @"not", @"on", @"one", nil];
groupWords = [[NSArray alloc] initWithObjects:group1, group2, nil];
在 tableView:cellForRowAtIndexPath: 我试图将单元格的文本设置为“Group#”,将详细文本设置为单词列表。我可以为每个单元格设置文本标签,但我似乎无法弄清楚如何传递字符串数组来设置每个详细文本标签。
例子:
第一组
一个,并且,找到,去,拥有
第 2 组
这里,跳,不,上,一个
这是我目前所拥有的:
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [groups objectAtIndex:[indexPath row]];
NSString *detailWords = [self.groupWords objectAtIndex:[indexPath row]];
NSLog(@"%@", detailWords);
cell.detailTextLabel.text =
return cell;
非常感谢任何帮助。
【问题讨论】:
标签: ios uitableview master-detail detailtextlabel