2012-07-01 36 views
0

我有4 ViewControllersstartViewController作爲初始視圖控制器。這包含我的介紹。完成後,它將[self presentViewController:vc animated:YES completion:NULL];放入我的menuViewControllerViewController導航


startViewController ------> menuViewController ------> C1ViewController 
              \ 
              \ ------> ImportantViewController 

以我menuViewController對於兩個ViewController像上面說明的按鈕。此外,我提出了他們在這個視圖:[self presentViewController:vc animated:YES completion:NULL];我回到menuViewController這個[self dismissModalViewControllerAnimated:YES];

我想要是讓ImportantViewController是像父視圖或者即使我去其他意見的MAINVIEW。我需要的是當ImportantViewController提交時,當我去C1ViewControllermenuViewController它不會被釋放,或其內容仍然會保留。

可能嗎?如何?

我不太瞭解父母和孩子的視圖控制器,所以我不知道在我的問題中實現什麼。謝謝。

順便說一句,我使用的故事板。

+0

爲什麼不使用'UINavigationController'呢? –

+0

就使用它而言,我在'UINavigationController'中不太好。我的按鈕不在工具欄中,我知道'UINavigationController'是用於工具欄的視圖,我想。 – Bazinga

回答

0

使ImportantViewController一個UINavigationController的根視圖,你會提出一個UINavigationController代替ImportantViewController的,

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:YourImportantViewControllerOBject]; 

//insted of presentModalViewControlle with YourImportantViewControllerOBject you do 
[self presentModalViewController:navigationController animated:YES]; 
在ImportantViewController

我們提出新的視圖控制器,你會做以下

[self.navigationController pushViewController:yourC1ViewController animated:YES]; 
+0

我應該在哪裏開始實施導航控制器,因爲我正在使用故事板。和林有點新的導航控制器,在我的基本知識是它需要與工具欄呈現。 – Bazinga

+0

你可以做故事板中的導航欄http://maybelost.com/2011/10/tutorial-storyboard-in-xcode-4-2-with-navigation-controller-and-tabbar-controller-part1/ –

+0

我可以問題由導航控制器完成?或者這只是這樣做的正確方法? – Bazinga

0

我不是100%你想做什麼,但如果你使用ARC,將ImportantViewController設置爲__strong它將會保留給你。爲什麼不通過以編程方式在ImprotantViewController.m中創建所需的視圖控制器來使ImportantViewController成爲父級?

// ImportantViewController.m 
// non ARC 
FirstChildViewController *firstChild = [[FirstChildViewController alloc] [email protected]"FirstChildViewController" bundle:nil]; 

//set firstChild.view position here if needed. e.g. .center = CGPointMake(x,y); 

//now add firstChild to the parent 
[self addSubview:firstChild]; 
[firstChild release]; 

您可以對第二個視圖或任意數量的視圖執行相同操作。我覺得這比呈現視圖控制器更好。您還可以將核心動畫添加到子視圖並創建一個不錯的用戶界面。

這是回答您的問題嗎?也許我沒有得到你想要的東西。 :)

+0

我不能去ImportantViewContoller,除非在MenuViewController中按一個按鈕,所以如何以及在哪裏實現它,我也使用故事板。 – Bazinga

+0

你想去ImportantViewController?您可以連接故事板中的視圖,然後使用該按鈕作爲觸發器。我認爲這篇文章確實是你需要的。 (如果你已將其他視圖拖入主要的stroyboard,請跳至步驟5)http://kurrytran.blogspot.se/2011/07/simple-ios-5-tutorial-using-storyboard.html – jarryd

+0

不,不,我一直呈現視圖直到ImportantViewController,然後當我轉到其他視圖時呈現ImportantViewController時,我希望ImportantViewController仍然保留,其內容未被釋放。 – Bazinga

相關問題