15
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ViewControllerのToolBarを出したり消したり

Posted at

二つの画面、仮にAとBとする、を遷移させた時にAではNavigationControllerによるツールバーを表示させたいけど、Bでは表示させたくないとき

ViewControllerA(ToolBar残す)
    override func viewWillAppear(animated: Bool) {
        self.navigationController?.setToolbarHidden(false, animated: true)
    }
ViewControllerB(ToolBar消す)
    override func viewWillAppear(animated: Bool) {
        self.navigationController?.setToolbarHidden(true, animated: true)
    }

最初はviewDidLoad()に書いてたんだけど、それだとB(ToolBar消したい方)からA(ToolBar残したい方)に戻った時にToolBarが消えたままになってしまった。
どうやらviewDidLoad()は初回読み込み時にしか呼ばれないらしく、画面上に現れた時はviewWillAppear関数が呼び出されるらしい。

間違ってたらゴメンナサイ

15
14
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
15
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?