2012-12-30 69 views
3

我從故事板實例化視圖控制器。每次我調用instantiateViewControllerWithIdentifier時,我都想新增一個視圖控制器的新實例。它不會做我想要的,相反,它總是返回相同的視圖控制器實例。我猜不是使用故事板,我應該以編程方式創建視圖控制器。在深入研究之前,是否真的不可能從故事板問一個新的視圖控制器實例?從storyboard創建視圖控制器的不同實例instantiateViewControllerWithIdentifier

編輯:我對這種行爲是錯誤的,顯然故事板的行爲完全如我所料,即instantiateViewControllerWithIdentifier每次都會返回一個新實例。

回答

6

這是一個有點奇怪:從official doc中提到: This method creates a new instance of the specified view controller each time you call it。 您是否100%確定每次調用此方法時都返回相同的實例。

否則是你需要明確地instanciate你的自定義視圖控制器。

+0

感謝tiguero,你是對的。每次我打電話時它都會創建一個新實例。不知道爲什麼我上次看到相同的地址。 –

相關問題