2012-07-13 74 views
2

我想手動啓動視圖控制器使用故事板。使用故事板手動啓動視圖控制器。

這是寫在代碼中,而不是連線。我嘗試過:

self initWithNibName:(NSString *) bundle:(NSBundle *) 

但我不確定它們是否被歸類爲筆尖或它們被歸類爲故事板中的類別。任何幫助將非常感謝!

回答

6

聽起來像是你正在尋找這個方法:

AlertContainerViewController *alertContainerViewController = 
[[UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:NULL] 
instantiateViewControllerWithIdentifier:@"alertContainer"]; 

你需要給在故事板視圖控制器對象的唯一標識,並指定子類。你通過財產督察做這兩件事。

+0

虐待這個嘗試謝謝。 – jimbob 2012-07-13 12:14:00

+0

爲什麼'bundle:NULL'而不是'bundle:nil'? – 2015-08-27 20:44:48

相關問題