Xcode 6.x/iOS 8 Hides Status Bar in Landscape Orientation

后端 未结 3 1981
臣服心动
臣服心动 2021-02-13 18:36

Application build with Xcode 6.x automatically hides the status bar in Landscape orientation (iPhone). The same application when compiled with Xcode 5.x doesn\'t do that.

<
相关标签:
3条回答
  • 2021-02-13 19:13

    Set "View controller-based status bar appearance" to YES in Info.plist

    Then place the following code in the desired view controller:

    - (BOOL)prefersStatusBarHidden {
        return NO;
    }
    
    0 讨论(0)
  • 2021-02-13 19:23

    Best possible solution

    It's basically a two step process:

    1). Set "View controller-based status bar appearance" to NO, in your project's Info.plist file.

    2). Force the status bar hidden status to NO, in application:didFinishLaunchingWithOptions:, using the following code:

    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
    

    And, voila!

    Note: It's important to use both the setStatusBarHidden:withAnimation: statements above, to force the status bar hidden state.


    Reference: On iOS8, displaying my app in landscape mode will hide the status bar but on iOS 7 the status bar is displayed on both orientations

    0 讨论(0)
  • 2021-02-13 19:23

    I'm using

    #define IS_IOS8 SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")
    
    -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
        [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
    
        if (IS_IOS8){
                [[UIApplication sharedApplication] setStatusBarHidden:NO];
        }
    }
    
    0 讨论(0)
提交回复
热议问题