首页 > 解决方案 > How to implement both UIViewController stack behaviour

问题描述

I noticed that WhatsApp has a somewhat neat navigation behaviour on their iOS app. See the following:

enter image description here

There are two navigation stack behaviour here:

  1. UINavigationController as a child of UITabBarController
  2. UITabBarController as a child of UINavigationController

How to achieve both of this at the same time, just like WhatsApp? Does it uses a custom UINavigationController?

Currently my implementation only does number 2 and not number 1. I do know that to do number 1 I have to make the UINavigationController as a child of UITabBarController, but I will lose number 2.

However if I implemented both, I will get weird result where I get two navigation bar, like:

enter image description here

标签: swiftuinavigationcontrolleruitabbarcontroller

解决方案


在您给出的示例中,看起来他们有一个UITabBarController作为根视图控制器。Settings 是导航控制器内的视图控制器。

当您点击Data & Storage时,它​​会将另一个视图控制器推送到设置导航控制器的堆栈中。

当您按下帮助时,它会执行相同的操作 - 但当帮助视图控制器被推入堆栈时,选项卡栏会隐藏。

推/退时请参阅隐藏/显示标签栏。迅速采取一些方法来做到这一点


推荐阅读