iOS:UITableView - >带有数据的DetailView init

时间:2012-09-03 12:46:14

标签: ios uitableview detailview

最好的方法是从带有数据的TableView初始化DetailView吗?

我需要“发送”一个对象来填充所有标签和ImageViews。

我的代码更改视图:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.navigationController pushViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"detailView"] animated:true];
}

MAIK

2 个答案:

答案 0 :(得分:2)

DetailViewController *viewController = (DetailViewController*) [self.storyboard instantiateViewControllerWithIdentifier:@"detailView"];
viewController.myProperty1 = object1;
viewController.myProperty2 = object2;
[self.navigationController pushViewController:viewController animated:YES];

答案 1 :(得分:1)

只需从故事板中实例化ViewController并在推送ViewController之前进行设置

YourViewControllerclass * vc = (YourViewControllerclass*) [self.storyboard instantiateViewControllerWithIdentifier:@"detailView"];
[vc setupMethodForObject: object];
[self.navigationController pushViewController:vc animated:YES];