我有幾個控制器,並使用Typhoon將對象作爲屬性注入到這些控制器中。我使用Plist集成。我發現有時候這個對象並沒有像預期的那樣注入到視圖控制器中。颱風從故事板向視圖控制器注入財產
例如,MainTabBarController是初始視圖控制器,SplashViewController是其他一些視圖控制器。我已經將該對象注入了代碼中的屬性。驗證該對象是否注入到MainTabBarController中。
在某個時候,我需要從MainTabBarController呈現SplashViewController如下:
SplashViewController *vc = [[UIStoryboard storyboardWithName:@"Main"
bundle:[NSBundle mainBundle]]
instantiateViewControllerWithIdentifier:@"SplashNavigationController"];
[self presentViewController:vc
animated:YES
completion:nil];
當我試圖訪問在SplashViewController對象,它失敗了。該屬性不包含該對象。
經過一番研究,我發現,我通過調用獲得的分鏡[UIStoryboard storyboardWithName:@「主」 包:一個NSBundle mainBundle]不是TyphoonStoryboard,但MainTabBarController的是TyphoonStoryboard。我因此將其更改爲:
SplashViewController *vc = [self.storyboard
instantiateViewControllerWithIdentifier:@"SplashNavigationController"];
[self presentViewController:vc
animated:YES
completion:nil];
然後SplashViewController包含注入的對象。我想確認是否預期這種行爲,並且這是處理這類問題的正確方法。
非常感謝!
注意:對不起,這在文檔中並不是很清楚。有所改正。 – 2015-03-31 05:06:39