2
votes

I was working on a sidemenu app in ionic v1. Everything works fine in the browser. But when i install the app in device, the header bar appears with some padding at the top. This shows a space between the status bar and header bar. I have tried all the possible ways but not able to solve it. Heres a screenshot of the issue.

enter image description here

I installed statusbar plugin and updated the preference value in config.xml.

Here is my config.xml for iOS

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.iton.vbuzz" version="1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>My App</name>
<description>
  My App V1.0
</description>
<content src="index.html"/>
<access origin="*"/>
<preference name="phonegap-version" value="cli-6.2.0" />
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="ShowSplashScreenSpinner" value="false" />
<preference name="FadeSplashScreen" value="true" />  
<preference name="FadeSplashScreenDuration" value="1.0" /> 
<preference name="AllowInlineMediaPlayback" value="true" />
<preference name="ShowSplashScreenSpinner" value="false" />
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#D6D6D6"/>
<preference name="StatusBarStyle" value="lightcontent" /> 
<preference name="orientation" value="portrait" />
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
<preference name="target-device"              value="universal" /> 
<preference name="prerendered-icon"           value="true" /> 
<preference name="detect-data-types"          value="true" /> 
<preference name="exit-on-suspend"            value="false" /> 

<platform name="ios">
<splash src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" height="1136"/>
<splash src="resources/ios/splash/Default-667h.png" width="750" height="1334"/>
<splash src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" height="768"/>
<splash src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
<splash src="resources/ios/splash/Default-Portrait~ipad.png" width="768" height="1024"/>
<splash src="resources/ios/splash/Default@2x~iphone.png" width="640" height="960"/>
<splash src="resources/ios/splash/Default~iphone.png" width="320" height="480"/>
<splash src="resources/ios/splash/2048X1536-04.png" width="2048" height="1536" />
<splash src="resources/ios/splash/Default-667h@2x~iphone.png" width="750" height="1334" />

<icon src="resources/ios/icon/icon.png" width="57" height="57"/>
<icon src="resources/ios/icon/[email protected]" width="114" height="114"/>
<icon src="resources/ios/icon/icon-40.png" width="40" height="40"/>
<icon src="resources/ios/icon/[email protected]" width="80" height="80"/>
<icon src="resources/ios/icon/icon-50.png" width="50" height="50"/>
<icon src="resources/ios/icon/[email protected]" width="100" height="100"/>
<icon src="resources/ios/icon/icon-60.png" width="60" height="60"/>
<icon src="resources/ios/icon/[email protected]" width="120" height="120"/>
<icon src="resources/ios/icon/[email protected]" width="180" height="180"/>
<icon src="resources/ios/icon/icon-72.png" width="72" height="72"/>
<icon src="resources/ios/icon/[email protected]" width="144" height="144"/>
<icon src="resources/ios/icon/icon-76.png" width="76" height="76"/>
<icon src="resources/ios/icon/[email protected]" width="152" height="152"/>
<icon src="resources/ios/icon/icon-small.png" width="29" height="29"/>
<icon src="resources/ios/icon/[email protected]" width="58" height="58"/>
<icon src="resources/ios/icon/[email protected]" width="87" height="87"/>
<config-file parent="UIStatusBarHidden" platform="ios" target="*-Info.plist">
  <false/>
</config-file>
<config-file parent="UIViewControllerBasedStatusBarAppearance" platform="ios" target="*-Info.plist">
  <true/>
</config-file>
</platform>

<plugin spec="https://github.com/apache/cordova-plugin-console.git
 " name="org.apache.cordova.console" source="git" version="0.2.13" />


<plugin spec="https://github.com/apache/cordova-plugin-device.git" name="org.apache.cordova.device" source="git" version="0.3.0" />


 <plugin spec="https://github.com/apache/cordova-plugin-splashscreen.git" name="cordova-plugin-splashscreen" source="git" version="4.0.1-dev" />


  <plugin spec="https://github.com/phonegap-build/StatusBarPlugin.git" name="com.phonegap.plugin.statusbar" source="git" version="1.1.0" />


  <plugin spec="https://github.com/apache/cordova-plugin-geolocation.git" name="cordova-plugin-geolocation" source="git" version="2.4.1-dev" />


  <plugin spec="https://github.com/apache/cordova-plugin-network-information.git" name="cordova-plugin-network-information" source="git" version="1.3.1-dev" />


  </widget>

In my app.js I defined :

if (window.StatusBar) {
  if (ionic.Platform.isAndroid()) {
  StatusBar.backgroundColorByHexString("#608628");
} else {
  StatusBar.styleLightContent();
}
}

please help me sort out this issue. Thanks in advance

1
Hi, did you manage to solve this issue ? - noor
I had the same issue but didn't fix it directly. I had to add a javascript code to check if the device platform is ios, then on each page init do this: $(".toolbar").css('paddingTop', 0); AND some times I do this: $(".page__content").css('top', 0); - Tariq

1 Answers

1
votes

You can add viewport-fit=cover to viewport metadata tag in index.html file as below

<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">

Reference: https://blog.ionicframework.com/ios-11-checklist/

Works fine with iOS 11.2 as well.