1

我有兩個VC:StepThreeViewController和QuoteViewController。 我想通過使用委託B/C一旦我有數據,將數據從QuoteViewController傳遞迴StepThreeViewController,我想彈出/關閉QuoteViewController並將數據傳遞到StepThreViewController。傳遞數據VC代表iOS

我收到一個錯誤,發現委託協議沒有找到!我遵循YouTube教程,閱讀了很多關於StackOverflow的評論,但似乎無法找到錯誤!

我也確保我的#import頭文件在那裏。

GitHub的我的代碼可以在這裏找到: https://github.com/aspirasean/BoxRocket.git

謝謝!

+0

我想你可能錯誤地上傳至Github上。我只看到.h和.m文件。沒有項目文件或故事板文件。 – Ricky

+0

@Ricky該項目現在上傳到我的git存儲庫上,但爲了防止它崩潰,您需要在AppDelegate.m中輸入您自己的Parse API密鑰。感謝您的幫助。 – Aspirasean

+0

@瑞奇我讓它通過「heightField」,但我把它作爲一個佔位符。我最終試圖從QuoteViewController傳回「int quote」,並將其顯示在StepThreeViewController的「quoteLabel」中。 – Aspirasean

回答

2

我想這可能並不需要QuoteViewController.h已導入"StepThreeViewController.h「下。我有評論指出,行,可以沒有任何錯誤編譯。

#import <UIKit/UIKit.h> 
//#import "StepThreeViewController.h" 
#import "MBProgressHUD.h" 

在情況下,如果你需要使用StepThreeViewControllerQuoteViewController,你可能想看看這篇文章:Cannot find protocol declaration

更新

StepThreeViewController.h你應該: -

@property (nonatomic, strong) QuoteViewController *controller; 

然後在viewDidLoad,你應該

self.controller.delegate=self; 

你將不得不作出的StepThreeViewController是的委託QuoteViewController爲了委託方法工作。

要了解更多關於在Objective-C的代表,您可以訪問:How do I create delegates in Objective-C?

+0

你知道,那工作!現在我需要弄清楚數據是否真的傳回來了。謝謝您的幫助! – Aspirasean

+0

現在我在StepThreeViewController中創建的方法在QuoteViewController中沒有被調用,我正在調用[self.delegate transferQuote:@「STRING」];有任何想法嗎? – Aspirasean

+0

更新了上面的答案。讓我知道它是否有效。 – Ricky