0

UIViewController堆棧如下所示:Muiltple Modal UIViewControllers |解僱top模式的UIViewController只有

+------ UIViewController_C (presented) 
+---- UIViewController_B (presented) 
+-- UIViewController_A (pushed) 

當我打電話-dismissViewController:animatedUIViewController_CUINavigationController駁回UIViewController_CUIViewController_B一起,按照動畫的文檔上_C,並且沒有對_B

什麼是最順從的方式來解僱_C只有

+0

請分享您的代碼。在一般情況下,它應該工作。 – malex

+0

- 找到解決方案;將在8小時後添加,因爲由於我的可憐的代表,我無法寫出它。 – atdfairfax

+0

謝謝@malex - 超類;我大體上和你一樣思考,並會盡快與我分享(T-4小時)。 – atdfairfax

回答

0

嘗試推動到UIViewController_A本UIViewController_B如下代碼後,如下

UIViewController_B *bbp=[[UIViewController_B alloc]initWithNibName:@"UIViewController_B" bundle:nil]; 
UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:bbp]; 
passcodeNavigationController.navigationBar.hidden=YES; 
[self.navigationController presentModalViewController:passcodeNavigationController animated:YES]; 
[passcodeNavigationController release]; 

現在來自UIViewController_B嘗試呈現在UIViewController_C下面的代碼。

UIViewController_C *bbp=[[UIViewController_C alloc]initWithNibName:@"UIViewController_C" bundle:nil]; 
UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:bbp]; 
passcodeNavigationController.navigationBar.hidden=YES; 
[self.navigationController presentModalViewController:passcodeNavigationController animated:YES]; 
[passcodeNavigationController release]; 

視圖控制器的每個後退按鈕上的最後一個東西寫在下面的代碼行。

[self dismissModalViewControllerAnimated:YES]; 

如果你想要比下面的評論更多的幫助。

0

一個解決辦法:

UIViewControllers呈現模態不在一定deallocated - dismissViewController:animated

這意味着,通過傳遞到UIViewController_A參考通過_B_C,可以通過調用UIViewController_A-presentViewController:animated-dismissViewController:animated用於相應UIViewControllers

代碼:

1 UIViewController_B

- (void) showUIViewController_C { 

    [self dismissViewControllerAnimated:TRUE completion:^{ 
     UIViewController_C *controller_C = [[UIViewController_C alloc] init]; 
     controller_C.parentController = self; 
     [self.parentController controller_C animated:TRUE completion:nil]; 
    }]; 
} 

2. UIViewController_C

- (void) dismissUIViewController_C { 

    [self dismissViewControllerAnimated:TRUE completion:^{ 
     [self.parentController.parentController presentViewController:self.parentController animated:TRUE completion:nil]; 
    }]; 
} 

當我使用*parentController爲任何Y類的命名慣例我們以前的UIViewController在堆棧上可能是。

由於我在完成塊中調用-dismiss-present,所以暫時回落到UIViewController_A,儘管實際上看起來很有趣。

相關問題