繁体   English   中英

iOS / objective-c / xcode:在代码中实例化DetailView控制器

[英]IOS/objective-c/xcode: Instantiate DetailView Controller in Code

我有一些代码用于启动在情节提要中创建的带有情节提要ID的模式视图控制器。 对于新情况,我正在尝试对其进行调整,以提供一个ViewController,它实际上是主导航系统中表格的详细视图。 如果可能的话,我正在尝试在应用中跳来跳去。

在这种情况下,VC不应是模态的。 相反,我想将用户带到表的普通详细视图。

为了使其更具挑战性,我需要局部视图具有对象数据。 幸运的是,这应该出现在起始VC中。

这是我启动模式VC的代码。

 UIStoryboard *storyBoard = self.storyboard;
         detailVC *newVC =
         [storyBoard instantiateViewControllerWithIdentifier:@"detailView"];
         //pass object to new VC
         detailVC.object = _object;//pass data object
         UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController: dareVC];
         [self presentModalViewController:nav animated:YES];

编辑:以下代码会启动非模式VC。 但是,初始详细视图没有数据。 数据已保存,因此,如果我返回数据,就可以了,但是最初,我得到了没有数据的通用屏幕。

  detailVC *secondViewController =
         [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
         [self.navigationController pushViewController:secondViewController animated:YES];
         secondViewController.object=_object;
  detailVC *secondViewController =
         [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
         secondViewController.object=_object;
         [self.navigationController pushViewController:secondViewController animated:YES];

首先实例化它。 然后设置数据。 然后推。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM