Search code examples
iosios7ios7-statusbar

iOS 7 Status bar issues on Landscape mode


I have a signature screen in my application that is suppose to show in Landscape, but the iPhone status bar displays in Portrait mode. How to get the Status bar to show in Landscape mode instead of portrait mode? I tried setting the Landscape orientation to status bar in ViewDidLoad, but no luck..

I use presentViewController to push screen,

enter image description here

Please find the below snippet of code to push the screen to Landscape mode.

// Override to allow orientations other than the default Landscape orientation.
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}


- (BOOL) shouldAutorotate {
    return YES;
}


- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeRight;
}

Any help is greatly appreciated!

Thanks, Ramesh


Solution

  • Resolved by adding the following methods,

    - (void)viewWillAppear:(BOOL)animated {
        [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
        [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
    
    }