2014-05-22 35 views
0

你好,我有两个故事板。让我们称他们为storyboard1和storyboard2。在没有赛格的故事板之间传递数据

我想将storyboard1的数据传递给storyboard2,这里是我的代码。

在storyboard1:

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"IndicesDetail" bundle:nil]; 
DataIntegrationIndexDetailViewController *cl = (DataIntegrationIndexDetailViewController *)[sb instantiateViewControllerWithIdentifier:@"indicesDetail"]; 

cl.transitioningDelegate = self; 

[self presentViewController:cl animated:YES completion:nil]; 

和storyboard2,我所谓的价值是这样的:

NSLog(@"sel index:%@",_delegate.selectedIndexCode); 

我得到的结果为空。

我也尝试这样的,在storyboard1:

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"IndicesDetail" bundle:nil]; 
DataIntegrationIndexDetailViewController *cl = (DataIntegrationIndexDetailViewController *)[sb instantiateViewControllerWithIdentifier:@"indicesDetail"]; 

cl.selectedIndex = @"test"; 

[self presentViewController:cl animated:YES completion:nil]; 

但它给我一个错误。

那么我如何将数据从一个故事板传递到另一个故事板?

+0

我的方法是使用一个应用程序模型类保持“共享应用程序信息”。这可以使用单例实例进行。 – Floydian

回答

0

尝试:的

[self.navigationController pushViewController:cl animated:YES]; 

代替[self presentViewController]

+0

不应该手动调用这个方法,如果使用UINav控制器.... – KING

+0

他不使用segue,所以我们需要调用'pushViewController' –

+0

感谢它解决我的问题..这里是我的工作代码:UIStoryboard * sb = [UIStoryboard storyboardWithName:@“IndicesDetail”bundle:nil]; DataIntegrationIndexDetailViewController * cl = [[DataIntegrationIndexDetailViewController alloc] init]; cl.selectedIndexCode = @“hehe”; [self.navigationController pushViewController:cl animated:YES]; – Herahadi

相关问题