Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphoneX not call prefersStatusBarHidden

info.plist

<key>UIViewControllerBasedStatusBarAppearance</key>
    <true/>

UIViewController

override var prefersStatusBarHidden: Bool{
        return true
   }

when i use 6p ,it's ok but
iphoneX ,it's can't call and StatusBar not hidden

like image 221
loseDream Avatar asked Jun 06 '18 07:06

loseDream


People also ask

Why is prefersstatusbarhidden not being called?

Maybe not a solution to the OP problem, but what could also be the cause for prefersStatusBarHidden not being called is if you have used a second window in your app delegate, eg for displaying a splash screen, and you did not hide it after the splash was shown - then that window gets the events that lead to calling these functions.

Why can’t I make phone calls on iPhone X?

Sometimes the network signal is so weak it cannot handle even a simple voice-only phone call. For some, iPhone X uses only a 3G network instead of 4G, which is another huge drawback. If this sounds familiar to you, check the next part of the article to find what can cause the connectivity problems on your iPhone X.

How to fix Apple phone not receiving calls?

[Solution] Apple Phone not Receiving Calls 1 Reset your network settings. Go to Settings > General > Reset > Reset Network Settings. 2 Try to make or receive calls in another location. 3 Switch to a different network band.... See More....

How to implement prefersstatusbarhidden in uinavigationcontroller?

Property prefersStatusBarHidden is being called on the root view controller of the current view controller. This means that if your app is based on a UISplitViewController for example, you must implement the property in a custom UISplitViewController class. Assuming you have a ViewController contained within UINavigationController.


1 Answers

You need to check if your view controller is included in a container (i.e. UINavigationController). If that is the case, the full procedure is this:

1) Set the View controller-based status bar appearance value in info.plist file to YES

2) In your child controller add this code:

override var prefersStatusBarHidden: Bool{
        return true
   }

3) Add this extension:

// gives control of the status bar appearance to the top controller
extension UINavigationController {
    override open var childViewControllerForStatusBarHidden: UIViewController? {
        return self.topViewController
    }
}

You already have point 1 and 2. Same logic applies to UITabBarController

like image 196
Claus Avatar answered Nov 03 '22 21:11

Claus