On iOS8, displaying my app in landscape mode will

2019-01-10 10:49发布

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

navigationController.isNavigationBarHidden returns NO.

Why is iOS 8 doing this?

10条回答
相关推荐>>
2楼-- · 2019-01-10 11:28

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

  [self setNeedsStatusBarAppearanceUpdate];

And this to implementation itself

-(BOOL)prefersStatusBarHidden{
    return NO;
}
查看更多
我只想做你的唯一
3楼-- · 2019-01-10 11:28

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

查看更多
仙女界的扛把子
4楼-- · 2019-01-10 11:28

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

查看更多
戒情不戒烟
5楼-- · 2019-01-10 11:29

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.

查看更多
Luminary・发光体
6楼-- · 2019-01-10 11:31

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.

查看更多
成全新的幸福
7楼-- · 2019-01-10 11:32

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
    }
查看更多
登录 后发表回答