内容简介:翻译自:https://stackoverflow.com/questions/15832706/instantiateviewcontrollerwithidentifier-and-pass-data
我在我的应用程序中使用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 controller viewController.foo = bar; [self presentViewController:navigationController animated:YES completion:nil];
翻译自:https://stackoverflow.com/questions/15832706/instantiateviewcontrollerwithidentifier-and-pass-data
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- VUE父子组件传递数据
- Vue 中父子组件数据传递
- vue组件之间的数据传递方法
- Vue使用props父子组件传递数据
- react新更新的context传递数据
- 风铃虫 2.2.1 发布,新增数据传递功能
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
深度探索C++对象模型
斯坦利•B.李普曼 (Stanley B. Lippman) / 侯捷 / 电子工业出版社 / 2012-1 / 69.00元
作者Lippman参与设计了全世界第一套C++编译程序cfront,这本书就是一位伟大的C++编译程序设计者向你阐述他如何处理各种explicit(明确出现于C++程序代码中)和implicit(隐藏于程序代码背后)的C++语意。 本书专注于C++面向对象程序设计的底层机制,包括结构式语意、临时性对象的生成、封装、继承,以及虚拟——虚拟函数和虚拟继承。这本书让你知道:一旦你能够了解底层实现模......一起来看看 《深度探索C++对象模型》 这本书的介绍吧!