ios – instantiateViewControllerWithIdentifier并传递数据

ios – instantiateViewControllerWithIdentifier并传递数据,第1张

概述我在我的应用程序中使用Storyboard,我想将数据从一个视图传递到另一个视图. 而不是使用segues我使用instantiateViewControllerWithIdentifier.在这种情况下,我从我的第一个TableViewController实例化到一个NavigationController,它附加了第二个TableViewController,因为我需要在第二个TableVie 我在我的应用程序中使用Storyboard,我想将数据从一个视图传递到另一个视图.

而不是使用segues我使用instantiateVIEwControllerWithIDentifIEr.在这种情况下,我从我的第一个tableVIEwController实例化到一个NavigationController,它附加了第二个tableVIEwController,因为我需要在第二个tableVIEwController中导航.现在我想将我的第一个tablevIEwController中的数据传递给我的第二个tablevIEwController,具体取决于单击了哪一行.在这种情况下,newtopVIEwController将是我的NavigationController但我现在的问题是如何将数据从firsttableVIEwController传递到secondtablevIEwController.

- (voID)tableVIEw:(UItableVIEw *)tableVIEw dIDSelectRowAtIndexPath:(NSIndexPath *)indexPath    {        Nsstring *IDentifIEr = [Nsstring stringWithFormat:@"%@top",[menuArray objectAtIndex:indexPath.row]];        UIVIEwController *newtopVIEwController = [self.storyboard instantiateVIEwControllerWithIDentifIEr:IDentifIEr];    }
解决方法 如果实例化navigationController,则可以使用vIEwControllers属性获取导航控制器的内部vIEwController.

像这样的东西:

UINavigationController *navigationController = [self.storyboard instantiateVIEwControllerWithIDentifIEr:IDentifIEr];MBFancyVIEwController *vIEwController = navigationController.vIEwControllers[0];// setup "inner" vIEw controllervIEwController.foo = bar;[self presentVIEwController:navigationController animated:YES completion:nil];
总结

以上是内存溢出为你收集整理的ios – instantiateViewControllerWithIdentifier并传递数据全部内容,希望文章能够帮你解决ios – instantiateViewControllerWithIdentifier并传递数据所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1102615.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存