2012-04-13 79 views
-2

我有n个文件。我附加了n个文件到表视图。实际上n个文件都是一个文件夹。但是当我将这些文件追加到表视图时,它们被附加到表视图中行由逗号分隔。如何在表视图中将它们拆分成不同的行。请给我建议,并请帮助我。如何在ios中执行字符串操作?

+0

没有看到您现有的代码,很难提供任何指导。 – 2012-04-13 11:58:45

+0

感谢响应我会告诉我的代码 – DurgaPrasad 2012-04-13 12:02:05

+0

“0.rtf”, “1.pdf.rtf”, “2.rtf”, “3.rtf”, “4.rtf”, “5。 rtf“, ”6.rtf“, ”7.rtf“, ”8.rtf“, ”9.rtf“, ”Untitled.pdf“我有我的字符串像this.All这些字符串被追加表格视图中的单行。如何在每个单元格中显示其中的一个单元格 – DurgaPrasad 2012-04-13 12:10:44

回答

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; 
} 
+0

Yeah.i做到了,但是当我将该数组变量添加到单元格时,它将显示单个行中的所有数据(用逗号分隔) – DurgaPrasad 2012-04-13 12:03:32

0

存储与每个数组元素一个文件名的数组文件列表,并使用indexPath.row选择合适的一个。

如果您需要拆分单个字符串,请使用componentsSeparatedByString:

相关问题