Swift – TabBarController – > ViewController – > NavigationController
我有以下情况:
我有一个TabBarController与一些选项卡(ViewControllers)。
当我在这些ViewControllers之一,我点击一个button,我想segue到一个NavigationController,仍然看到tabbar …
这是我做的:
- 我创build了一个新的ViewController(DetailViewController)
- 我将这个新的ViewController(DetailViewController)embedded到NavigationController中
- 我从“tabbarcontroller中embedded的viewcontroller”创build一个segue(Show)到“new navigationcontroller”
-
我编码:
func buttonTapped { performSegue(withIdentifier: "shownavicontroller", sender: nil } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { let destinationNavigationController = segue.destination as! UINavigationController let targetController = destinationNavigationController.topViewController as! DetailViewController }
出了什么问题:
- NavigationController从下到上滑动…它应该从左向右滑动
- NavigationController中的BackButton丢失
- NavigationController中的TabBar缺less…
有人可以帮我解决这个问题吗?
感谢和问候!
你做错了。 你不应该直接将UIViewControllerembeddedtabBarController来获得你想要的结果。
从Storybaord,
如果你是从storyboarddevise你的应用程序,那么你应该添加一个UIViewController
并将这个UIViewController
对象embedded到UINavigationController
,然后将这个NavigationController
embedded到UITabBarController
。 所以,如果上面的UIViewController
的button被按下,你需要打开另一个UIViewController
而不是从底部到顶部,但从左到右,并期待在顶部栏的自动返回button,并隐藏底部栏。 然后,您需要在ViewController
上方(在NavigationController
embedded – >embedded在TabBarController
)创build一个Push / Show Segue窗体给您将要打开的新UIViewController。 在调用push / show segue之前,你需要写下波纹线。
self.tabBarController?.hidesBottomBarWhenPushed = true
根据你的问题,我相信这是你所需要的: