UITableView传递数据

时间:2013-02-07 14:25:42

标签: iphone xcode json uitableview

对不起,这可能是一个很多新手问题,但我过去几个小时一直在圈子里。

我有一张桌子,当按下该行时弹出到第二个视图。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    BlogDetailViewController *blogDetailViewController = [[BlogDetailViewController alloc] initWithNibName:@"BlogDetailViewController" bundle:nil];
    blogDetailViewController.title = [idArray objectAtIndex:indexPath.row];
    blogDetailViewController.newsArticle = [content objectAtIndex:indexPath.row];
    [self.navigationController pushViewController:blogDetailViewController animated:YES];
}

然后在我的下一个视图中,我有一个文本框,我想显示[content objectAtIndex:indexPath.row];的内容。

到目前为止,我已将此添加到secoundview.h

@interface BlogDetailViewController : UIViewController{

    NSDictionary *newArticle;
    IBOutlet UITextView *descTextView;

  }


@property (nonatomic, copy) NSDictionary *newsArticle;

我也有@synthesize新闻文章;在secoundview.m上,并将IBOutlet联系起来。

到目前为止我已经

- (void)viewDidLoad
{
    [super viewDidLoad];

    descTextView.text = [content];


    // Do any additional setup after loading the view from its nib.
}

希望能解释我可以上传zip的内容,如果没有意义的话。

谢谢

2 个答案:

答案 0 :(得分:0)

我对这个问题感到有些困惑,因为它不是很清楚,但我认为你所做的是将数据从表格视图传递到另一个视图,但下一个视图是不是显示数据?在这种情况下最简单的做法是添加viewWillAppear代码,将内容(newArticle?)放入descTextView

答案 1 :(得分:-1)

descTextView.text = [NSString stringWithFormat:newsArticle];这显示了textview

中的字符串