简体   繁体   中英

iOS Status Bar Height Incorrect when In a Call

I'm seeing an issue where if a user opens my app while they are in a call, or doing something else that causes the status bar to be double-height, the entire layout gets pushed down by the height of the status bar.

For example, if the user enters a call and they are already in the app , then the layout will look like this:

在此处输入图片说明

However, if a user is already in a call and they enter the app, the layout will look like this (the nav bar being cut off at the bottom of the image is part of the issue, not a problem with the screenshot):

在此处输入图片说明

All of my layouts have been created through a StoryBoard and are using AutoLayout. I have also recently reviewed and fixed any AutoLayout constraints that seemed to be bad or out of place.

If anyone has guidance about what might be going on, or a way to fix this, it would be much appreciated!

In your main view controller, where your tab bar controller lives, make sure you override viewDidLayoutSubviews() and resize the UITabBarController as such:

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    self.myTabViewController.view.frame = self.view.bounds
}

Use following:

func viewWillLayoutSubviews{
     self.view.layoutIfNeeded()
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM