【发布时间】:2019-05-02 19:11:47
【问题描述】:
我在 AppDelegate 中使用 4 个视图控制器(使用 .xib)以编程方式创建了 UITabBarController。当用户点击 ViewController (VC-A) 上的某个按钮时,它会显示另一个 VC (VC-B) 并覆盖标签栏。所以我想VC-B的按钮上有一个tabbar。
我尝试将 VC-B 添加为 tabbarcontroller 的子项。我尝试在两个上都显示 .present(vc) 和 .show(vc):VC-A 和 VC-A.TabBarController
在 AppDelegate 中创建控制器:
let controllers = [tabViewController1,tabViewController2,tabViewController3,tabViewController4]
tabBarController.viewControllers = controllers
window?.rootViewController = tabBarController
在 VC-A 中展示
self.tabBarController?.present(controller, animated: false, completion: nil)
【问题讨论】:
-
您对
present的实际工作方式感到困惑。它实际上在当前 VC 之上呈现了一个 VC。所以它覆盖了整个屏幕,你的 tabBar 将不可见。如果要保留 tabBar,请将 tabBarController 嵌入到 navigationController 中并改用push
标签: swift uitabbarcontroller tabbar