Open malwatte opened 6 years ago
Unfortunately, this is a known bug with UIWebview, and is apparently not an issue with Ionic v1. Here is the open radar report: http://www.openradar.me/34518947
I guess we have to wait for Apple to fix UIWebview.
If you can not use WKWebView in your app - one option is to lock the screen orientation to portrait and also set the app to full screen (no status bar). Obviously this is not an ideal workaround, but maybe would work for you in the short term.
oh :(
If anybody needs,I was able to fix this by upgrading:
Try to remove and reinstall this plugin
@malwatte: Did you fixed this issue? How? I am having the same issue.
Hi guys if you trigger a force reflow you can get away with this nasty bug. E.g. set top 1px and then remove after 100 ms.
@samithaf: Can you please add code here?
@Sunilchhipa , Consider moving to Ionic 3/4 if you are still using Ionic 1. My solution was that.
@Sunilchhipa
Here is a sample code and you can optimise the code block to only run on iPhonex. Just add this code snippet to a Angular.js run block.
window.addEventListener("orientationchange", function() {
var $tab = document.querySelectorAll('ion-tabs');
if ($tab.length > 0) {
$tab[0].style.top = "1px";
$timeout(function() {
$tab[0].style.top = 0;
}, 100);
}
});
@samithaf: Thanks..!!
@malwatte, What version of 3/4 fixed your issue. Im running 4.1.2 and its still broken. It seems like I have tried all of the "tricks" and nothing has been successful.
@austinemayer give a try by force reflow. Looks it take a while to set safe area inset prop when device rotation occurs
@austinemayer, Im on Ionic 3.9.2. It works fine on iPhone X. You need to use ionic-webview too.
@malwatte Yeah that was the problem. I did not reinstall the ionic-webview plugin. Thanks for your help!
Similar to the workaround posted above, this is what I used for my Ionic 1 project and it fixed the iPhone X/XS screen rotation issue:
window.addEventListener("orientationchange", function() {
var originalMarginTop = document.body.style.marginTop;
document.body.style.marginTop = "1px";
setTimeout(function () {
document.body.style.marginTop = originalMarginTop;
}, 100);
}, false);
The purpose of the code is to cause the document.body.style.marginTop to change slightly and then reverse it, which will force the safe-area-inset-* to re-calculate immediately. It doesn't necessarily have to be "1px". You can pick a suitable value that doesn't cause your UI to flicker but achieves it purpose.
It fixes the following two issues: (1) header bar too tall when rotated to landscape, and (2) header bar obscured by the "notch" when rotated back to portrait.
I was using ionic 1.2.4 and followed https://blog.ionicframework.com/ios-11-checklist/ to fix my app for iPhone X. Then I tested in iPhone X simulator and there are positioning issues in UI. To make sure issues are not due to my custom css or JS, I created a new ionic 1 project and tested. But issues exists there too.
cordova cli: 8.0.0 ionic cli: 3.19.1 xcode: 9.2
This is what I did,
ionic start "Ionic1" tabs --type ionic1
bower install
<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">
<ion-nav-bar class="bar-positive">
ionic cordova plugin add https://github.com/apache/cordova-plugin-statusbar
Changed the orientation to landscape.![screen shot 2018-01-25 at 12 28 11 pm](https://user-images.githubusercontent.com/2534778/35375338-b0b42f18-01cc-11e8-9cb5-afb58e26a8bb.png)
Changed the orientation back to portrait and this happened.![screen shot 2018-01-25 at 12 31 30 pm](https://user-images.githubusercontent.com/2534778/35375348-b8b49b58-01cc-11e8-8728-6a8e63972b86.png)
issue 1: UI (header and footer) gets mispositioned in portrait after orientation change. issue 2: Landscape titlebar is too high.
Then I added cordova-plugin-ionic-webview plugin and it worked fine.
Looks like safe regions are not working properly in UIWebview.
Please help.