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 1465
暗喜
暗喜 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:08

    It's not an issue but a feature of an iOS 8. The status bar will be hidden in landscape mode in iOS 8, even Apple's applications also having same behaviour.

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

    We solved this by forcing an orientation change unseen by the user. In the first view controller that loads, add:

    - (void)viewWillAppear:(BOOL)animated
    {
        NSNumber *orientationLeft = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
        NSNumber *orientationRight = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
        [[UIDevice currentDevice] setValue:orientationLeft forKey:@"orientation"];
        [[UIDevice currentDevice] setValue:orientationRight forKey:@"orientation"];
    }
    
    0 讨论(0)
  • 2020-12-02 11:12

    Swift 3

    override func viewDidLoad() {
            super.viewDidLoad()
            UIApplication.shared.setStatusBarHidden(true, with: .none)
            UIApplication.shared.setStatusBarHidden(false, with: .none)
    ///
        }
    

    and add inside Info.plist this:

    UIViewControllerBasedStatusBarAppearance boolean value NO

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

    They are keeping us gainfully employed by giving us more work.

    or...

    They've made other changes which cause bits to take up more space than they used to. With iOS 7 and the advent of things like the "Top Layout Bar Guide", the easy availability of the status bar in the swipe down screen, reclaiming the status bar space to be usable and other little hints many people predicted the status bar might be getting phased out as a standard part of the UI.

    There is also quite a bit of buzz about new device sizes due to the changes they've made in iOS 8 trying to make it easier to code for a bunch of different sizes.

    It's pure speculation, but I don't think they landscape status bar will return in iOS 8.

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

    Try this

    Add below code in didRotateFromInterfaceOrientation

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

    EDIT
    NO NEED TO WRITE CODE IN ALL VIEW CONTROLLER
    Set View controller-based status bar appearance to NO in plist and add below code in root view controller's viewDidLoad

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

    Demo project
    https://www.dropbox.com/s/uumneidk4wom5md/demoStatusBar.zip?dl=0

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

    Swift 3 (As of June 2, 2017)

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear()
        self.setNeedsStatusBarAppearanceUpdate()
    }
    
    override var prefersStatusBarHidden : Bool {
        return false
    }
    
    0 讨论(0)
提交回复
热议问题