LoginSignup
4
2

More than 5 years have passed since last update.

hidesBottomBarWhenPushedの3階層目以降の挙動について

Last updated at Posted at 2017-09-16

検証環境

  • XCode8.3.3
  • iOS10.3.1

hidesBottomBarWhenPushed

UITabBarControllerの中にUINavigationControllerを持っていて下層に下っていくとする。
このとき、2階層目以降はタブを表示したくない場合、pushされるviewControllerのhidesBottomBarWhenPushedをtrueにするとタブが隠された状態でpushされる。

viewController.hidesBottomBarWhenPushed = true
navigationController?.pushViewController(viewController, animated: true)

3階層目以降の挙動

ただタブを隠すだけなら上記で良いが、仮に3階層目以降でタブを表示したい場合(そんな場合があるかは置いておいて)の挙動が気になったので軽く検証してみた。

最前面のviewControllerがhidesBottomBarWhenPushed=trueの(=タブが表示されていない)状態で、さらにpushした場合の挙動を試したところ、以下の結果だった。

hidesBottomBarWhenPushed tabBar
指定なし(false) 表示されない
false 表示されない
true 表示されない

つまり挙動としては既にタブが表示されていない場合は、hidesBottomBarWhenPushedの値に関わらずタブが表示されない。

もう少し調べて見ると以下のstackoverflowが見つかった。
https://stackoverflow.com/questions/5641465/hidesbottombarwhenpushed-no-not-working

If YES, the bottom bar remains hidden until the view controller is popped from the stack.

とのことらしいので、スタックされているviewControllerの中にhidesBottomBarWhenPushed=trueのものがあると表示されないという事らしい。

ただ、

This is what the documentation for hidesBottomBarWhenPushed says

って書いてるけど見つけられなかった。。

参考

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2