Platform.width() does not work on iOS 10.1


#1

Hi, I have the next source code, but always this.platform.width() return 0 on iOS 10.1.
It’s work fine on Android.

   this.platform.ready().then((readySource) => {
        this.maxPxByRatio = (RATIO * this.platform.width()) + 'px';
    });

any workaround?


#2

I have the same issue with Android as well. My HTC m7 will return 0 when I ask for the same info in platform ready in some occasions (not always). We have previously also experienced cases where width and height was swapped around even if the app had been set to be portrait only, so we always check if the returned width is smaller than the height and return the smallest.

constructor(public platform: Platform) {
  platform.ready().then((readySource) => {
    let pw = this.getPlatformWidth();
    ....
  }
}

getPlatformWidth() {
  if (this.platform.width()<this.platform.height()) {
    return this.platform.width();
  } else {
    return this.platform.height();
  }
}