turbolinks / turbolinks-ios

Native iOS adapter for building hybrid apps with Turbolinks 5
MIT License
880 stars 92 forks source link

Allow webview to display under the status bar/ notch #168

Closed gearoidoceallaigh closed 4 years ago

gearoidoceallaigh commented 4 years ago

Whilst the webview in my Turbolinks project allows content to scroll "underneath" the notch/status bar, it seems as though it's impossible to get the webview to start underneath it by default.

It seems like the common solution to achieve this is:

webview.scrollview.contentInsetAdjustmentBehavior = .never

However, this has brought me no joy.

I've tried removing/adding constraints around containers but no luck.

Does anyone happen to know if this is possible using the (superb) turbolinks-ios library?

zachwaugh commented 4 years ago

Do you have a screenshot of what you mean? Besides the native side of it, you also need to have the HTML configured correctly - https://webkit.org/blog/7929/designing-websites-for-iphone-x/, specifically the viewport setting:

<meta name='viewport' content='initial-scale=1, viewport-fit=cover'>
gearoidoceallaigh commented 4 years ago

Hi @zachwaugh

I forgot to specify I've already added the viewport-fit=cover to viewport meta tag.

Below is a primitive example of what I'm trying to accomplish.

image

I would expect the above to display "howdy" underneath the status bar.

Obviously this isn't my intended use. I'm trying to get the page background image to display underneath the status bar/notch. Unfortunately, it displays underneath both of these, just like the howdy text.

gearoidoceallaigh commented 4 years ago

I should also mention that the view controller in this instance is a child of a navigation controller whose navigation bar is (temporarily) hidden.

EDIT:

After some further digging I found that scroll views which are children of navigation controllers have some weird behaviour with the content insets:

https://medium.com/@wailord/the-automaticallyadjustsscrollviewinsets-rabbit-hole-b9153a769ce9

I found that adding the following to my ViewController solved the problem:

self.automaticallyAdjustsScrollViewInsets = false

Unfortunately, this method is marked for deprecation. It's replacement? Yep, its the suggested fix above (webview.scrollview.contentInsetAdjustmentBehavior = .never) which still has no effect.

I don't think this is a turbolinks-specific issue so I will close this ticket.