The status bar displays content down only when the application starts with the call status bar turned on

So, I have weird behavior here. I have a basic iOS app encoded in Swift. It uses WKWebView along with several other small features.

One of the main problems at the moment is the Call Status Bar. If I switch the status bar in a call when the application is open, it looks great:

enter image description here


Although, if I switch the status bar in a call before opening the application and then launching it, the layout becomes all weird:

enter image description here


Along with switching the status bar to off, it then becomes even weirder (20 pixels of white space at the top):

enter image description here


The problem occurred even when the call status bar was switched while the application was opening, although I fixed it (hence the first image that looks great) using this simple single-line interface:

webView.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight] 

How can I get my webview for this, even if the application is open during call activation?

+5
source share
1 answer

I also ran into this problem and solved it by checking the size of the status bar when opening the application, and if it is 40 points, then it listens for UIApplicationDidChangeStatusBarFrame notifications, and when it happens, it moves the frame views to .zero .

For example, in Swift 4:

 var sbshown: Bool = false override func viewDidLoad() { super.viewDidLoad() //check height of status bar when app opens, and set a boolean if open let sbheight = UIApplication.shared.statusBarFrame.height NSLog("status bar height %f", sbheight) if (sbheight == 40) { sbshown = true } //set up to receive notifications when the status bar changes let nc = NotificationCenter.default nc.addObserver(forName: NSNotification.Name.UIApplicationDidChangeStatusBarFrame, object: nil, queue: nil, using: statusbarChange) } 

Then we implement the method of resizing and changing the position when the status bar disappears:

 func statusbarChange(notif: Notification) -> Void { if (sbshown) { sbshown = false self.view.frame.origin = .zero self.view.frame.size.height = UIScreen.main.bounds.height } } 

So, re-positioning should occur only if the panel was shown when the application was opened, and not if the panel is displayed and hidden when the application is already open.

0
source

Source: https://habr.com/ru/post/1244406/


All Articles