-2

n 個のファイルがあります。その n 個のファイルをテーブル ビューに追加しました。実際には、その n 個のファイルは 1 つのフォルダーに属しています。カンマで。テーブルビューでそれらを異なる行に分割する方法。提案をお願いします。助けてください。

4

3 に答える 3

1

fileNamesメソッド内にあるファイル名を配列に入れますviewDidLoad

そして、次のようにメソッドを実装します。

-(NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section
{
    return [fileNames count];
}

-(UITableViewCell*)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];

    }
    cell.textLabel.text = [fileNames objectAtIndex:indexPath.row];
    return cell;
}
于 2012-04-13T11:59:36.107 に答える
0

ファイルのリストを配列要素ごとに1つのファイル名で配列に保存し、を使用して適切なファイルindexPath.rowを選択します。

componentsSeparatedByString:単一の文字列を分割する必要がある場合に使用します。

于 2012-04-13T12:00:26.800 に答える
0

コンポーネントSeparatedByString を使用します。

于 2012-04-13T12:00:45.373 に答える