Ionic Cordova - iPhone X safe area has changed with iOS 13+

我与影子孤独终老i 提交于 2021-02-17 06:35:07

问题


I'm writing an app with cordova, Ionic v1, and AngularJS 1.5.3.

ionic info

Ionic:

   ionic (Ionic CLI) : 4.10.3 (C:\Users\User\node_modules\ionic)
   Ionic Framework   : ionic1 1.3.5
   @ionic/v1-toolkit : 1.0.22

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 8.1.0, ios 6.1.0, browser 5.0.4, windows 4.4.3
   Cordova Plugins       : cordova-plugin-ionic-webview 4.1.3, (and 17 other plugins)

System:

   Android SDK Tools : 26.1.1 (C:\Users\User\Documents\Android\sdk)
   NodeJS            : v10.21.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.14.4
   OS                : Windows 10

In the past the new iPhone X came out and I added some code to make adustments for the "safe area".

css

body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

html

<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

It was working for me for a long time.

However, I noticed that with the iPhone X and XR with iOS 13.6 I'm having issues with the "safe area".

As I'm using cordova-ios 6.1.0 I'm using WkWebView only.

<platform name="ios">
    <preference name="WKWebViewOnly" value="true" />

I'm finding that I have to multiply the safe-area-inset-bottom by 4 to make any progress.

$calculated_padding_bottom: calc(env(safe-area-inset-bottom) * 2);

body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) $calculated_padding_bottom env(safe-area-inset-left);
}

What could be wrong?


回答1:


It has changed to "constant" as of 11.2

body {
  padding: constant(safe-area-inset-top) constant(safe-area-inset-right) constant(safe-area- inset-bottom) constant(safe-area-inset-left);
}

Why are you using Ionic 1?



来源:https://stackoverflow.com/questions/63287926/ionic-cordova-iphone-x-safe-area-has-changed-with-ios-13

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!