0

テーブルビューに配列の配列を入力しましたが、セルラベルとしてテキストを表示する方法がわかりません。

配列内の配列の「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;
}
4

1 に答える 1

0

配列の配列があるため、配列内の配列にアクセスする必要があります。

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

indexPath.rowこれは、 からインデックス(テーブルの行) にある配列を取得しexercisesArrayます。

[excersizeArray objectAtIndex:indexPath.row]

これは、その配列(内側の配列)から(暗示されているように)文字列を取得します。

于 2011-10-26T21:35:15.883 に答える