Black
Black

Reputation: 20302

xcode - webview content is showing in status bar

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

Upvotes: 0

Views: 1868

Answers (3)

FrugalResolution
FrugalResolution

Reputation: 655

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
    

Upvotes: 0

Faysal Ahmed
Faysal Ahmed

Reputation: 7669

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.

Upvotes: 1

Mike H
Mike H

Reputation: 507

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

Upvotes: 4

Related Questions