以编程方式删除NavigationController [英] Removing NavigationController Programmatically

查看:80
本文介绍了以编程方式删除NavigationController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该应用程序包含多个导航控制器. (下面的示例)

the application contains more than one navigation controller. (example below)

NavigationController1 ----> ViewController1 ---> TabBarController --> 
NavigationController2 ----> ViewController2

无论何时ViewController1消失,我都会使用NavigationController.view.removeFromSuperview

whenever ViewController1 willDisappear i remove the NavigationController using NavigationController.view.removeFromSuperview

每当加载ViewController2时面临的问题.我只是看到黑屏而已.可能是什么问题?

the problem im facing whenever ViewController2 loads. i just see a black screen nothing else. what might the problem be?

以及删除navigationController的最佳方法是什么?

and what is the best way to remove the navigationController?

推荐答案

黑屏不过是UIWindow.删除NavigationController时,窗口没有任何NavigationController.因此,一旦删除第一个NavigationController,就必须为窗口设置NavigationController.

The black screen is nothing but UIWindow. When you are removing NavigationController , the windows doesn't have any NavigationController. So you will have to set NavigationController for window as soon as you remove your first NavigationController.

您可以尝试这样:

 let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate

 appDelegate.window?.rootViewController = YOUR_NAVIGATION_CONTROLLER_OBJECT;

这篇关于以编程方式删除NavigationController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆