0

The problem is simple, the Profile viewController has a NavigationBar just under the status bar.
I push another viewController on top of the current one. This new viewController hides the status bar.

When I go back to the Profile viewController, the navigationBar has moved up by the size of the status bar height.

I tried to force a layout refresh in my viewWillAppear but it doesn't work.

Any ideas?

enter image description here

Mohammad Kanan
  • 4,452
  • 10
  • 23
  • 47
Mikael
  • 2,355
  • 1
  • 21
  • 45

3 Answers3

1

Use this below code,

override func viewWillDisappear(animated: Bool) {
    navigationController?.setNavigationBarHidden(navigationController?.navigationBarHidden == false, animated: false)
}

hope its helpful

Iyyappan Ravi
  • 3,205
  • 2
  • 16
  • 30
0

Implement viewDidDisappear in that presented viewcontroller and show status bar again before come to profileview controller.

  override func viewWillDisappear(animated: Bool) {


    UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.Fade)
}
Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
  • Ok thank you! that's ALMOST the fix, in fact, it works if I use viewWillDisappear but not in viewDidDisappear, but I would prefer to manage the layout in the profile view controller itself if possible. Because if somebody else create another view hiding the status bar again... it will bug... – Mikael May 25 '16 at 12:53
  • You're welcome... :) This is the right way. If somebody hides status bar in any VC then he must implement viewdiddisappear or willdisappear to shows it again. this is the only standard solution. If you manage profileview, at this time this is profile view but somebody hide status bar in another view and it's base view is not profileview then? so it is better to implement willdisappear or diddisappear to show statusbar again – Ketan Parmar May 25 '16 at 13:01
  • can you update your answer with viewWillDisappear as it actually doesn't work with viewDidDisappear(). You were the one to put me on the right track. It's quite sad that it is the only way to do it though... – Mikael May 25 '16 at 17:08
  • @Mikael : Updated answer with `viewWillDisappear`... :) – Ketan Parmar May 26 '16 at 04:20
0

add code in plist file hide status bar in your app:

<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
Bhadresh Kathiriya
  • 3,147
  • 2
  • 21
  • 41