LoginSignup
3
1

More than 3 years have passed since last update.

iOS14でタブバーが消えたまま戻らなくなる現象に遭遇した

Posted at

Overview

画面遷移の度に hidesBottomBarWhenPushed = true すると popToRootViewController() した時にtabBarが戻らなくなりました。

iOS13では発生しなかったため、iOS14のバグと思われます。
Developer Forumsにも上がっていました

雑に再現コード

長いので折りたたみ
FirstViewController.swift
final class FirstViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "First"
    }
}

extension FirstViewController {
    @IBAction func next(_ sender: Any?) {
        guard let vc = storyboard?.instantiateViewController(identifier: "second") else { return }
        vc.hidesBottomBarWhenPushed = true
        navigationController?.pushViewController(vc, animated: true)
    }
}
SecondViewController.swift
final class SecondViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "Second"
    }
}

extension SecondViewController {
    @IBAction func next(_ sender: Any?) {
        guard let vc = storyboard?.instantiateViewController(identifier: "last") else { return }
        vc.hidesBottomBarWhenPushed = true
        navigationController?.pushViewController(vc, animated: true)
    }
}
LastViewController.swift
final class LastViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "Last"
    }
}

extension LastViewController {
    @IBAction func popToRoot(_ sender: Any?) {
        navigationController?.popToRootViewController(animated: true)
    }
}

対応策

↑のコードの場合であればSecondViewControllervc.hidesBottomBarWhenPushed = trueを消してしまえばLastViewControllerからのpopToRootViewControllerでタブバーが戻ってくるようになります。
ただし、複雑な画面遷移だと思わぬ副作用が発生するリスクもあるので、バグ修正されるのを待った方がいいのかも😅

3
1
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
3
1