ios - Swift - 摇动手势会关闭子视图控制器
问题描述
我有两个视图控制器,它们在情节提要中定义为,
UIViewController -> (Show Detail Segue) -> UITabBarController
我的问题是;我正在使用一个调用netfox
来调试我的HTTP
请求的库。这个图书馆UI
是由 触发的Shake Gesture
。但是当我第一次来到UITabBarController
Shake Gesture
模拟器时不起作用。在第二次,它 消除了ViewController
当前在屏幕上的,显然是一个孩子,UITabBarController
并回到最初的UIViewController
. 这就像用segue连接两个ViewController
s并从孩子那里调用一个。modal
self.dismiss()
我试图改变rootViewController
,UIApplication
UIApplication.shared.keyWindow.rootViewController = self
在viewDidLoad()
方法中UITabBarController
,它奏效了。但是,对于此解决方案,缺少UINavigationBar
任何子项UINavigationController
中的项目(按钮、标题)。UITabBarController
我不知道为什么会这样。如果在我解决这个问题时有人帮助我,我将不胜感激。
解决方案
而不是使用
self.performSegue(withIdentifier:_)
调用这个UIViewController
已经奏效了:
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewControllerWithIdentifier("tabBarcontroller") as UITabBarController
UIApplication.sharedApplication().keyWindow?.rootViewController = viewController;
尊重这个答案。
推荐阅读
- python - 从 Python 网络应用程序:将数据插入电子表格(例如 LibreOffice / Excel),计算并保存为 pdf
- purescript - 如何定义一个空查询类型的 eval 函数?
- c# - C# 以异步方式与数据库交互,不起作用。
- r - R:箱线图仍显示已删除行的额外空间
- matlab - Matlab函数Contourc产生的Contour Levels代表什么
- c++ - C++ 标准是否允许 std::optional
无需开销即可实施 - sharepoint-2013 - 通过 Powershell 连接到外部 Sharepoint 本地站点
- python - 使用 Python 拆分数据并将排序数据分配到 excel 视图的列
- css - 在 2 行和 2 列中打破 4 个 div 响应
- extjs - 在 extjs 中定义商店与创建商店