sih*_*hao 0 iphone objective-c uitableview ios xcode4.3
新目标.我试图将2个值放入表格视图中.这是代码的一部分:
- (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;
}
Run Code Online (Sandbox Code Playgroud)
对于此行cell.textLabel.text = desc,[alDescArray objectAtIndex:indexPath.row];
,表格仅显示Alight Destination =而不添加值[alDescArray objectAtIndex:indexPath.row];
我做错了什么部分请帮忙
你应该用
cell.textLabel.text=[NSString stringWithFormate:@"%@ %@",desc,[alDescArray objectAtIndex:indexPath.row];
Run Code Online (Sandbox Code Playgroud)
要么
NSString *desc=[NSString stringWithFormart: @"Alight Destination = %@",[alDescArray objectAtIndex:indexPath.row] ];
cell.textLabel.text = desc;
Run Code Online (Sandbox Code Playgroud)
`
| 归档时间: |
|
| 查看次数: |
315 次 |
| 最近记录: |