xcode – webview content is showing in status bar
In this post, it hints that to ensure the status bar is not sitting over the webview, ie in capacitorjs’s case the app, you should add constraints to the storyboard.
However, in my xcode (latest), the storyboard for capacitor "Bridge view controller" does not allow me to apply constraints.. all the options are greyed out:
However, I cannot figure out how to get the ios status bar to not sit over the top of the app, and all the old Cordova and ionic methods do not appear to be working.
Whatever I do the status bar hand over the webview..
Any ideas or ios/capacitor js pro’s out there who could help?
2
Answers
I’m not familiar with Capacitor, but as an iOS developer a View Controller in not a visual element so it is not capable of having constraints.
You’ll need to figure out a way to access the
UIView
in Capacitor and then apply constraints the the view.Capacitor uses a single ViewController where the only view is a WKWebView that is full screen, so you can’t add any constraints to it.
What you should do to avoid the notch is to add this viewport meta tag
<meta name='viewport' content='initial-scale=1, viewport-fit=cover'>
to your index.html and respect the Safe Areas with the help ofenv()
CSS function and pre-defined environment variablessafe-area-inset-left
,safe-area-inset-right
,safe-area-inset-top
andsafe-area-inset-bottom
as described by Apple on this articleIf your app is not going to be scrollable and you don’t want to deal with the safe areas yourself, you can alternatively set the viewport meta tag to
<meta name='viewport' content='initial-scale=1, viewport-fit=contain'>
and add this to the
capacitor.config.json