![](/img/trans.png)
[英]Objective C: How to present modal view controller from appdelegate?
[英]How to present and dismiss modal view from appdelegate?
我在didFinishLaunchingWithOptions中,處於我的應用程序的appdelegate中,我想在選項卡欄控制器上加載模式導航控制器(我沒有類“ navigation controller”,但只有故事視圖中的導航控制器帶有視圖) “選擇”導航控制器的控制器)。 然后,我想回到標簽欄控制器。 在didFinishLaunchingWithOptions中,我使用了以下代碼,並且模式導航控制器可以正常工作:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
UINavigationController *loginController = [storyboard instantiateViewControllerWithIdentifier:@"Login Controller"];
self.window.rootViewController = loginController;
但是,當在我的模態視圖控制器中“導航”導航控制器時,我嘗試使用以下代碼返回到標簽欄:
[self dismissViewControllerAnimated:YES completion: nil];
什么都沒有。 怎么了 謝謝。
這就是我們將哪個視圖控制器設置為rootViewController(需要顯示firstViewController)的方式。
mainViewController = [[[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil] autorelease];
self.window.rootViewController = mainViewController;
采用
[self.navigatorcontroller presentviewController: Controller];
呈現視圖控制器
您可以通過以下方式消除它
[self dismissViewControllerAnimated:YES completion: nil];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.