0

here is my question gif: question GIF i use this code in my first VC

override func viewWillAppear(animated: Bool) {
    self.navigationController?.setNavigationBarHidden(true, animated: animated)
    super.viewWillAppear(animated)
    print("VC1 viewWillAppear")   
}

override func viewWillDisappear(animated: Bool) {
    self.navigationController?.setNavigationBarHidden(false, animated: animated)
    super.viewWillDisappear(animated)
    print("VC1 viewWillDisappear")
}

it refers to how to hidden when push to a vc

Community
  • 1
  • 1
  • What's the problem, your code is doing correctly as in your GIF? If you want to hide nav bar in second VC then put that code in your second VC – Tj3n Jul 19 '16 at 08:14
  • you see ,when i pop vc2 to vc1 ,and canceled this action, vc2's navigationbar is missed – user6602582 Jul 19 '16 at 08:35
  • Then in VC2's `viewWillAppear:` put the `self.navigationController?.setNavigationBarHidden(false, animated: animated)`, this make sure it will appear even if u cancel – Tj3n Jul 19 '16 at 08:37
  • i forget to say that i have already add that . but this question is also here – user6602582 Jul 19 '16 at 08:45
  • Actually when u cancel the pop gesture, it will call `viewWillAppear:` again in your VC2... i wonder why it not working also – Tj3n Jul 19 '16 at 08:47
  • You reproduce this behavior with simulator or on a real device? – Reinier Melian Jul 19 '16 at 20:41
  • @ReinierMelian yes .it happens in simulator and real device too. this question is same with the comment by fabb in Alan's answer . http://stackoverflow.com/questions/845583/iphone-hide-navigation-bar-only-on-first-page/2406167#2406167 – user6602582 Jul 21 '16 at 07:44

0 Answers0