0

我有一个来自应用程序委托的名为 delegate.allSelectedVerseEnglish 的 NSMutableArray,它有一些值,我能够获取数组计数,并且可以在 UITableView 中正确显示它。但现在我想在文本视图中显示它。我的 UITableView 代码是这样的

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

        return [delegate.allSelectedVerseEnglish count];
}


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

    static NSString *CellIdentifier = @"Cell";
    readCell *cell = (readCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"readCell" owner:self options:nil]; 
        cell = [nib objectAtIndex:0]; 

        cell.label.text = [NSString stringWithFormat:@"%d",indexPath.row+1];
        cell.textLabel.text =  [NSString stringWithFormat:@"  %@",[delegate.allSelectedVerseEnglish objectAtIndex:indexPath.row]];
        cell.textLabel.font = [UIFont fontWithName:@"Georgia" size:19.0];
    }
}

它在单元格中显示正确的值,但我只需要在 textview 中显示这个 delegate.allSelectedVerseEnglish 数组,例如textview.text = delegate.allSelectedVerseEnglish;. 怎么做?

提前致谢。

4

2 回答 2

5

取决于您希望如何格式化文本。
出于记录目的,我会使用[delegate.allSelectedVerseEnglish description];while 向用户展示[delegate.allSelectedVerseEnglish componentsJoinedByString:@"\n"];可能合适的东西。

于 2012-04-22T07:54:44.850 回答
2

你可以这样使用 -

NSString *stringToShow = nil;
for (NSString *stringObj in delegate.allSelectedVerseEnglish) {
    stringToShow = [stringToShow stringByAppendingString: [NSString stringWithFormat:@"%@",stringObj]];
}
cell.textLabel.text = stringToShow;
于 2012-04-22T07:57:21.577 回答