您也可以使用下面的代码。希望它可以帮助。
取2个可变阵列说 - ARRAY1和阵列2
在viewDidLoad中,分配的阵列和值存储在两个阵列。
(void)viewDidLoad
{
array1=[NsMutableArray alloc]init];
[array1 addObject:@"string1"];
[array1 addObject:@"string2"];
[array1 addObject:@"string3"];
array2=[NsMutableArray alloc]init];
[array2 addObject:@"int1"];
[array2 addObject:@"int2"];
[array2 addObject:@"int3"];
}
然后继续使用cellForRowAtIndexPath中的代码。
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] ;
}
cell.textLabel.text =[array1 objectAtIndex:indexPath.row];
cell.detailTextLabel.text =[array2 objectAtIndex:IndexPath.row];
return cell;
}
我会尝试n让你知道,谢谢 – Pooja 2011-01-31 15:28:30