Swift: Navigation Bar ist hiding although I call the required code?

Ellie

New Member
#1
I have two VCs with the same navigation Controller and on my first VC the navigation Bar should be hidden and the second one large. The two VC are connected via a push segue. But if I click on the back button which appears after a push segue the navigation Bar appears again although when the VC first appears there is no Navigation Bar. My code on the first VC:
Mã:
override func viewDidLoad() {
    super.viewDidLoad()
    navigationController!.navigationBar.isHidden = true
}
 

Admin

Administrator
Thành viên BQT
#2
The method viewDidLoad() is only called once so just but the line of code in the viewWillAppear method:
Mã:
override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    navigationController!.navigationBar.isHidden = true
}
 
Top