0

I am developing a webview app, which just loads our website. I noticed that the content of the website is showing in the status bar if you scroll down the page. Is this default iOS browser behaviour or can I fix this?

Website shows in status bar at the very top

Black
  • 18,150
  • 39
  • 158
  • 271

3 Answers3

4

You need to add your top constraint (a controller with web site) to the safe area. I hope it will fix your problem enter image description here

EDITED

Here is detailed screenshot how it's can be done: (also, about constraints, check this documentation)

enter image description here

Mike H
  • 487
  • 2
  • 13
  • Where do I find this? Can you add more screenshots please, it would be really helpful. – Black Jul 09 '19 at 10:26
  • 1
    Updated the answer, please, check it – Mike H Jul 09 '19 at 10:35
  • In your screenshot there is View which has the children View and Safe Area. But I only have View which has the child "Safe Area". How can I add the other View? – Black Jul 09 '19 at 10:43
  • There should be something like WebView (since you are displaying web content). Maybe web view is added in the code – Mike H Jul 09 '19 at 10:45
  • If I click on safe area and try to add a constraint then everything is grayed out and I can't interact with the settings. – Black Jul 09 '19 at 10:52
  • I restarted my project by following the following tutorial, now your answer works. https://www.youtube.com/watch?v=xQmZSKxOYvs – Black Jul 18 '19 at 13:05
1

For iOS 11 and upper OS create this issue during debug time. This will fix for the released version. I have faced this problem many times during work.

Don't know how but it happens.

So you can try to create a release version and check on your device.

Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50
0

The programmatically approach would be:

view.addSubview(webView)
let guide = view.safeAreaLayoutGuide
webView.topAnchor.constraint(equalTo: guide.topAnchor).isActive = true
webView.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true
webView.rightAnchor.constraint(equalTo: self.view.rightAnchor).isActive = true
webView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
    
FrugalResolution
  • 568
  • 4
  • 18