簡體   English   中英

在情節提要之間傳遞數據而不會造成混亂

[英]Passing data between storyboards with no segue

您好,我有兩個故事板。 讓我們將它們稱為Storyboard1和Storyboard2。

我想將數據從storyboard1傳遞到storyboard2,這是我的代碼。

在故事板1中:

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];

但這給我一個錯誤。

那么,如何將數據從一個情節提要板傳遞到另一個情節提要板?

您應該首先了解如何使用storboard。 http://www.raywenderlich.com/50308/storyboards-tutorial-in-ios-7-part-1

一種實現方法是使用單例類。

http://www.galloway.me.uk/tutorials/singleton-classes/

嘗試:

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

而不是[self presentViewController]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM