2011-10-26 60 views
0

我已經使用數組數組填充tableview,但我不知道如何顯示文本作爲單元格標籤。如何在tableView單元格中顯示文本標籤

我想使用數組中的「0」位置的字符串作爲文本標籤。

謝謝。

這裏是我的代碼:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    // Set up the cell... 
    cell.textLabel.text = [excersizeArray objectAtIndex:indexPath.row];  
    return cell; 
} 

回答

0

您需要在陣列中訪問數組,因爲你有一個數組的數組:

cell.textLabel.text = [[excersizeArray objectAtIndex:indexPath.row]objectAtIndex:0]; 

此獲得的索引indexPath.row數組(該表的行)從exercisesArray

[excersizeArray objectAtIndex:indexPath.row] 

這是從該數組(內部數組)得到的字符串(如您所暗示的那樣)。

+0

非常感謝! – novicePrgrmr

相關問題