title: iOS 8 - Rotation makes statusBar disappear even in portrait mode after toggling controls
body: <p>I'm having a lot of troubles with the new auto hiding of the status bar in iOS 8.</p>
  <p>In my app, I've got a view in which when the user taps once, the navigation bar and the status bar disappear.</p>
  <p>When in landscape, the status bar hides by itself and it's fine to me. I only need it in portrait mode.</p>
  <p>But the problem is that when the device is landscape and the bar are shown, when the user taps twice to toggle the bar (so showing), and turns the device in portrait mode, the status bar is still hidden.</p>
  <p>Basically I need to be able to hide the statusBar without interfere with its natural behavior on iOS 8, so I recap the scenario:</p>
  <ul>
  <li>User enters said view with tabBar and NavigationBar and statusBar;</li>
  <li>Taps once in the view and the bars disappear</li>
  <li>User rotates the device, statusBar not appearing - OK, I want this</li>
  <li>User taps again to show the bars - StatusBar still hidden, OK.</li>
  <li>User rotates from landscape to portrait and..</li>
  <li>statusBar still hidden  - NOT OK.</li>
  </ul>
  <p>MRW &gt; <a href="https://i.stack.imgur.com/cnFYj.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cnFYj.gif" width="300"></a><br />
  <sub>(source: <a href="http://rack.2.mshcdn.com/media/ZgkyMDEzLzA2LzEzL2Y0L1B1Y2suODkyZGIuZ2lmCnAJdGh1bWIJMTIwMHg5NjAwPg/c6538ddb/a38/Puck.gif" rel="nofollow noreferrer">mshcdn.com</a>)</sub></p>
  <p>I've tried to adjust the statusBar on willRotate, but I made a mess in which the statusBar would be visible when it wasn't supposed to. Code I'm using:</p>
  <pre><code>- (BOOL)prefersStatusBarHidden
  {
      return statusBarHidden;
  }
  
  -(void)toggleBars:(UITapGestureRecognizer *)gesture{
      CATransition *animation = [CATransition animation];
      animation.type = kCATransitionFromBottom;
      animation.subtype = kCATransitionFromTop;
      animation.duration = .2f;
      [animation setTimingFunction:[CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut]];
      
      
      BOOL toggleNavigationBar = self.navigationController.navigationBarHidden;
      [self.navigationController.navigationBar.layer addAnimation:animation forKey:nil];
      [self.navigationController setNavigationBarHidden:!toggleNavigationBar animated:YES];
      
      
      
      BOOL toggleTabHidden = self.tabBarController.tabBar.hidden;
      if(![[[NSUserDefaults standardUserDefaults] objectForKey:@&quot;showTabBar&quot;]isKindOfClass:[NSNull class]]){
          if([(NSNumber*)[[NSUserDefaults standardUserDefaults] objectForKey:@&quot;showTabBar&quot;]boolValue])
          {
              [self.tabBarController.tabBar.layer addAnimation:animation forKey:nil];
              [self.tabBarController setHideTabBar:!toggleTabHidden animated:YES];
          }
      }
      
      statusBarHidden = [UIApplication sharedApplication].statusBarHidden;
      [[UIApplication sharedApplication] setStatusBarHidden:!statusBarHidden withAnimation:UIStatusBarAnimationSlide];
      [self setNeedsStatusBarAppearanceUpdate];
  
      
      if (IS_IOS8){
          if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)){
              if (statusBarHidden){
                  [[UIApplication sharedApplication] setStatusBarHidden:YES];
              }
          }
      }
  
  }
  </code></pre>
  <p>I was thinking about setting a flag in which when the statusBar is hidden when in landscape and all the controls are there, on rotation it would trigger the statusBar. With no success, apparently..</p>
  <p>Any help highly appreciated.</p>