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

后端 未结 10 1466
暗喜
暗喜 2020-12-02 11:04

I want the status bar to be displayed in both orientations in iOS 8; it\'s being displayed properly in iOS 7.

navigationController.isNavigationBarHidden

相关标签:
10条回答
  • 2020-12-02 11:19

    I had the same issue! Fixed by addicting this to viewDidLoad

      [self setNeedsStatusBarAppearanceUpdate];
    

    And this to implementation itself

    -(BOOL)prefersStatusBarHidden{
        return NO;
    }
    
    0 讨论(0)
  • 2020-12-02 11:24

    To display status bar in landscape mode in ios 8, try following method

    - (BOOL)prefersStatusBarHidden {
        return NO;
    }
    

    Swift version

    override func prefersStatusBarHidden() -> Bool {
        return false
    }
    

    Swift 3, Xcode 8, iOS 10, /* ViewController.swift */

    override var prefersStatusBarHidden: Bool {
            return false
        }
    
    0 讨论(0)
  • 2020-12-02 11:27

    Jageen's solution is probably the best, with just one minor change i.e. instead of using viewDidLoad, it's better to use application:didFinishLaunchingWithOptions:.

    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.

    0 讨论(0)
  • 2020-12-02 11:29

    We fixed it by following the above steps and making sure that landscape left and right are both enabled.

    Under Project/Target/Deployment Info

    enter image description here

    0 讨论(0)
提交回复
热议问题