ios – instantiateViewControllerWithIdentifier并传递数据

栏目: IOS · 发布时间: 6年前

内容简介:翻译自: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


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

统计自然语言处理基础

统计自然语言处理基础

Chris Manning、Hinrich Schütze / 苑春法、李伟、李庆中 / 电子工业出版社 / 2005-1 / 55.00元

《统计自然语言处理基础:国外计算机科学教材系列》是一本全面系统地介绍统计自然语言处理技术的专著,被国内外许多所著名大学选为计算语言学相关课程的教材。《统计自然语言处理基础:国外计算机科学教材系列》涵盖的内容十分广泛,分为四个部分,共16章,包括了构建自然语言处理软件工具将用到的几乎所有理论和算法。全书的论述过程由浅入深,从数学基础到精确的理论算法,从简单的词法分析到复杂的语法分析,适合不同水平的读......一起来看看 《统计自然语言处理基础》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具