Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iphone的textview中显示数组值_Iphone_Objective C_Ios - Fatal编程技术网

在iphone的textview中显示数组值

在iphone的textview中显示数组值,iphone,objective-c,ios,Iphone,Objective C,Ios,我有一个名为bookmark的数组,它包含值,我在tableview单元格中显示它,我知道如何在tablecell中显示它。但我希望相同的数组在textview中显示它。这是我的tableview代码 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } //自定义表视图中的行数 - (NSInteger)tableView:(UITableView *)tableView nu

我有一个名为bookmark的数组,它包含值,我在tableview单元格中显示它,我知道如何在tablecell中显示它。但我希望相同的数组在textview中显示它。这是我的tableview代码

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
 }
//自定义表视图中的行数

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


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        UIImageView* img = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bgCELL3@2X-1"]];
        [cell setBackgroundView:img];
        [img release];
    }
    cell.textLabel.font =[UIFont fontWithName:@"Georgia" size:15];
    cell.selectionStyle = UITableViewCellSelectionStyleGray;
    cell.textLabel.text = [NSString stringWithFormat:@"%@ %@:%@ ",[[bookmarks objectAtIndex:indexPath.row] objectForKey:@"book"],[[bookmarks objectAtIndex:indexPath.row] objectForKey:@"chapter"],[[bookmarks objectAtIndex:indexPath.row] objectForKey:@"verse"],[[bookmarks objectAtIndex:indexPath.row] objectForKey:@"text"]];
    // Set up the cell...

    return cell;
}
我想用mytextview.text=?替换cell.textlabel.text。请帮助我完成此操作。
提前感谢。

您可以使用与
UILabel的文本相同的方式设置
UITextView的文本

 mytextview.text = [[bookmarks objectAtIndex:0] objectForKey:@"text"];
或者,例如,在循环中:

NSString *resultStr = @"";
for (id bookmark in bookmarks)
{
     resultStr = [NSString stringWithFormat:@"%@. %@", resultStr, [bookmark objectForKey:@"text"]]];
}
mytextview.text = resultStr;

你的文本视图在哪里?您想将文本视图添加到您的单元格中,还是您已经在其他地方有了文本视图,只想在那里显示此文本?您想在一个
UITextView
中显示它吗?@Nekto是,我想在一个文本视图中显示它。@ElanthiraiyanS我的文本视图不在uitableview中,它在tableview之外是一个不同的视图。我想在viewdidload方法中编写mytextview.text=