0

假設我有3個視圖控制器。我在vc0中啓動vc1,然後在vc1中啓動vc2。現在我想要解除vc2,之後只有vc0顯示在它後面。那可能怎麼樣?我讀了一些關於委託申報的內容。但無法理解。關閉視圖控制器以在背面顯示所需的一個

我有UISegmentcontrol,我從故事板顯示控制器 - vc0 = [self.storyboard instantiateViewControllerWithIdentifier = @「vc0」];並使其成爲它的子視圖[self.view addSubview:vc0.view]; Vc0是一個tableView,它有一個detailcontroller來呈現。當我點擊一個單元格時,它會顯示detailview,但是當detailview被解除時,實際的segmentcontrol.view會丟失。

一個例子會很棒。

PS:我沒有使用segue的viewControllers。相反,我使用presentModalViewController和dismissModalViewController。

+0

'vc1'和'vc2'都在同一時間模態呈現的? – Wain

+0

你想一次性關閉所有的視圖控制器嗎?來自vc0的 –

+0

,呈現vc1,然後來自vc1的vc2。我想從vc2直接進入vc0。可能? –

回答

0

在iOS 5中,你需要做的

[self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES] 

隨着iOS 6的dismissModalViewControllerAnimated的:已被棄用。

你需要調用

[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:^{ // Do something on completion}] 
//If you want to perform something while going through views or other wise keep completion to nil as shown in below code. 

[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil]; 

[self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES]; 
+0

任何想法,如果我有vc0作爲segementControl視圖的子視圖?我想下去segmentControl視圖。 –

+0

你可以把一些代碼,以便我可以理解你到底做了什麼,你想要什麼 –

+0

我有UISegmentcontrol我從故事板顯示控制器 - vc0 = [self.storyboard instantiateViewControllerWithIdentifier = @「 VC0" ];並使其成爲它的子視圖[self.view addSubview:vc0.view]; Vc0是一個tableView,它有一個detailcontroller來呈現。當我點擊一個單元格時,它顯示detailview,但實際視圖segmentcontrol丟失。當detailview被解僱時,我不希望這會丟失。 –

相關問題