2013-01-22 25 views
0

我已經成功地學習瞭如何使用委託。迄今爲止,我已經學會了如何通過prepareForSegue方法使用storyBoards將數據傳遞給secondViewController,然後使用Delegates將數據從secondViewController返回到第一個ViewController。使用委託將數據傳回給多個viewControllers

問題是,當我創建一個thirdViewController如下: ViewController >> secondViewController >> thirdViewController。 (代理協議設置在thirdViewController中)

我的委託工作正常,從thirdViewController傳遞數據到secondViewController。問題是從secondViewController傳遞迴的viewController

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ 

SecondViewController *page2 = [[SecondViewController alloc]init]; 
[[segue identifier] isEqual:@"page2"]; 
page2 = [segue destinationViewController]; 
page2.delegate = self; // this is the problem ?? 

}

我得到的錯誤是如下當:房產「代表」沒找到。 代表不能在多個視圖(在一個鏈中)像這樣工作的問題?

回答

0

的幾點提示:

  1. SecondViewController *page2 = [[Page2 alloc]init];
    什麼SecondViewControllerPage2之間的關係?

  2. 確保您在SecondViewController中定義了delegate

  3. 請確保您的#import "SecondViewController.h"viewController.m

+0

@anO感謝提示和是我改變了提示1的錯誤。儘管如此,沒有運氣。我重新編寫了代碼 - 這次沒有錯誤,但我又遇到了同樣的問題 - 任何其他想法? – pete

+0

什麼「同樣的問題」? – an0

+0

@anO我現在發現你不能鏈接委託消息。所以我試圖做的事情是不可能的。我所說的「同樣的問題」是,委託消息不能從第三控制器傳遞到第二個控制器和viewController。我知道我可以通過NSNotification來做到這一點,但我試圖與代表一起做。 – pete

相關問題