Ionic 4 - iOS status bar overlaps top tabs - ios

I'm trying to create a tabs bar at the top of my app, with no obvious header, but the iOS status bar is overlapping it. I've tried wrapping the ion-tabs tag in an ion-content tag that has padding but that didn't work. I wrapped the tabs in a header which fixed the padding issue, but then the pages loaded by the tab disappeared inside the header.
I've seen all the posts about headers being overlapped but those were years ago, that's been fixed in ion 4, and the solutions don't work for tabs anyways.
How can I solve this without removing the status bar?
iOS version: 11.4.1
ionic version: 4.0.5
Recreating:
Create the ionic tabs starter project
Change the tabs placement to top
Remove the header in home.html
<ion-tabs tabsPlacement="top">
<ion-tab [root]="tab1Root" tabTitle="Home" tabIcon="home"></ion-tab>
<ion-tab [root]="tab2Root" tabTitle="About" tabIcon="information-circle"></ion-tab>
<ion-tab [root]="tab3Root" tabTitle="Contact" tabIcon="contacts"></ion-tab>
</ion-tabs>

After reading and playing with #Bilow's answer, I found it sufficient to simply add margin to the ion-tabs element as a whole, like so:
ion-tabs {
margin-top: var(--ion-safe-area-top);
}
This added space for the status bar on iOS. On Android, which was already behaving properly, nothing changed, so this fix works cross-platform.

It seems that tabs are just hard to work with. I found a work around by using segments. I'll just need to spend some time to stylize them to look right.
Here is my new app.html code:
<ion-header>
<h2></h2>
<ion-segment [(ngModel)]="page" (ionChange)="segmentChanged($event)">
<ion-segment-button value="home">
<ion-icon name="home"></ion-icon>
</ion-segment-button>
<ion-segment-button value="about">
<ion-icon name="information-circle"></ion-icon>
</ion-segment-button>
<ion-segment-button value="contacts">
<ion-icon name="contacts"></ion-icon>
</ion-segment-button>
</ion-segment>
</ion-header>
<ion-content>
<ion-nav [root]="rootPage"></ion-nav>
</ion-content>
Having segments in the header worked for me, but in order to get the padding I needed I had to add an empty h2 tag. If there's a better way feel free to let me know, for now I'm happy with this.
For those of you that would like to do something similar I found the answer, posted by rapropos, here:
https://forum.ionicframework.com/t/having-a-hard-time-understanding-the-navigation-with-tabs/92918/9

With just a little bit more effort you'll able to keep using the ion-tabs. This is what I've came up with:
Add to your global scss (or wherever needed)
global.scss
.plt-ios {
ion-tab-bar {
padding-top: var(--ion-safe-area-top);
}
ion-header ion-toolbar.noSafeAreaPaddingTop{
padding-top: 0 !important;
}
}
Add the 'noSafeAreaPaddingTop'-class to every tab page using the ion-toolbar
YourPageTemplate.html
<ion-header>
<ion-toolbar class='noSafeAreaPaddingTop'>
<ion-title>Tab page title</ion-title>
</ion-toolbar>
</ion-header>
...
I'm not verry happy with this method neither, but it works with ion-tabs..

A better solution was obvious:
<ion-header>
<h2></h2>
</ion-header>
<ion-content>
<ion-tabs tabsPlacement="top">
<ion-tab [root]="tab1Root" tabTitle="Home" tabIcon="home"></ion-tab>
<ion-tab [root]="tab2Root" tabTitle="About" tabIcon="information-circle"></ion-tab>
<ion-tab [root]="tab3Root" tabTitle="Contact" tabIcon="contacts"></ion-tab>
</ion-tabs>
</ion-content>
I'm not sure why that took me so long to figure out...

Related

Ionic Keyboard issue while tap on SearchBar its scroll to top and invisible to user

I am working on Ionic 3.X version and On my Home Page I have one search bar.
Issue : While click on SearchBar its opening Keyboard from bottom and my searchBar and whole screen goes UP side and user unable to view or scroll after click on searchBar
issue in OS : iOS
Same code works in Android
Screen Shots:
HTML Code for Search Bar :
<ion-content padding class="home-content-background-color">
<div *ngIf="headerTextShowFlag">
<div text-center>
<img [src]="appLogo" width="100" height="100">
</div>
<ion-label style="text-align: center" class="text-color">Welcome</ion-label>
<hr class="hr-style">
<ion-label text-wrap padding style="text-align: center" class="text-color">
Please Enter Service Request Number</ion-label>
</div>
<div>
<ion-searchbar (ionInput)="getItems($event)"></ion-searchbar>
<ion-list style="height: 58%; overflow-y: scroll; margin: 0px">
<ion-item *ngFor="let Case of CaseArrayFiltered" (click)="selectCaseFromList(Case)">
{{ Case }}
</ion-item>
</ion-list>
</div>
</ion-content>
Unable to show search bar on top its always moving out of screen at first load while click on search bar at first time.
Disable scroll solve my problem but after adding below line my keyboard show/hide not working properly.
this.keyboard.disableScroll(true);
After lots of R&D on above issue I found solution with some code patch in my .ts file
Need to disable keyboard scroll so that my screen will not go up automatically while keyboard will show.
platform.ready().then(() => {
this.keyboard.disableScroll(true);
});
Also need to update my flag in this.zone()
this.zone.run(() => {
self.toggleHeader = false;
});
Above line of code will execute on main thread and will update flag & UI so based on this my issue was resolved and hope this will helps others who also facing same issue specially in iOS platform.
Thanks.

ionic ios all view blank after keyboard hide

in ionic login page , every time when i hide keyboard it will cause a full screen blank (element still there can be click and response) , and after editing input all recover normal. (Only iOS,android is fine,other page's input is fine so it should not be the keyboard plugin's problem)
Maybe this link help you. But it's temporary.
replace <ion-content> with <ion-scroll>
<ion-scroll direction="y" style="right: 0;bottom: 0;left: 0;position: absolute;" class="has-header has-subheader">
keyboard issue
You have to add this two attributes to ion-content padding="true" overflow-scroll="false"
<ion-content padding="true" overflow-scroll="false">
</ion-content>
It worked for me.

Image in Jquery Mobile Header overlaps main content

I'm developing a Cordova project, building the user interface with jQuery Mobile (first project using any of them), and I'm having problems adding a logo image to the header.
Since it makes the header bigger than default, the header overlaps the content in the main div as in this capture:
If I navigate to other page and return to this one, then everything looks like it should:
I've read that when jQuery Mobile initializes the page, the header image is not loaded and the header is much smaller, so I've tried
this is my html for the image:
<div data-role="header" data-id="header" data-position="fixed">
<h1>
<img src="img/flycosette_logo-88cb7efa9f6acfcaf246f8523e87805d.png" alt="FlyCosette"/>
</h1>
</div><!-- /header -->
And this my css in a custom file called after jQM files:
.ui-header img {
width: 100%;
}
I've tried the approach in the quoted link:
$(window).on('load', function () {
$(this).trigger('resize');
});
but it doesn't work for me.
I've also tried placing the image inside a div, instead <h1>, and setting the code for it instead of the image, playing with several properties, but it doesn't solve the problem and the image size does not display as well as in the screencaptures...
So, any idea on how to fix it?
When you get back to the page, JQM internally triggers an event called upateLayout which probably also adapts the content positioning relative to the header. Try triggering this yourself by doing something like:
$([your_page]).trigger("updatLayout");
See if this works. Maybe you need to call it on the header or content instead of the page.
After refactoring my code, I've been trying all different solutions once again, and it turns out that the initial solution:
$(window).on('load', function () {
$(this).trigger('resize');
});
from the post: https://stackoverflow.com/a/11110607/3708095
is what finally solved my problem.
I'm calling the script with that code after the </body> tag, below all the html (not sure about how was it being called before), and now is working.
Sorry for the inconveniences.

Gaps under tabs using JQuery UI in Firefox

I have been using JQueryUI for various aspects of my site, and a small tabbed menu set was working well, except in firefox. The image below shows the same code rendered in firefox on top, and IE9 below. Note the gap under the tabs and the (possible?) increase in padding inside the tab. I have removed all my stylesheets from the site (the 2nd image) leaving just the base JQuery UI one, but the gaps still appear, and only in firefox.
The js call is as basic as it can be:
$("#menuTabs").tabs();
It's not often I have display issues where IE is better than firefox... Having removed all the CSS I generated, and made sure there's no styles being applied, I'm at a loss as to where to look next!
If you can offer any suggestions as to what might be causing it, I'd be a happy chappie!
[EDIT]
After scaling back the code as far as I could, and using only 'known good' libraries, it turns out that it is caused by it being in a table cell!
Here's some code you can have a play with! http://jsfiddle.net/XVHTk/
It does however work when "Normalized CSS" is checked, so it could be padding inherited from the cell maybe?
[EDIT #2]
Right.
So.
It turns out that CSS styles applied to a table to remove padding and margins and borders and so forth are not enough. You have to include cellpadding="0" and cellspacing="0" in the table definition otherwise the jQuery tabs have some extra padding around them.
Odd.
jsFiddle with table and no extras: http://jsfiddle.net/XVHTk/1/
jsFiddle with table spacing/padding stripped: http://jsfiddle.net/XVHTk/2/
Why the HTML cell properties are being transferred into the tabs, I have no idea. I'm just happy to have fixed it!
This is caused by a bug in the ui-helper-clearfix class. See ticket #8442 and the associated fix. As you can see from the ticket, this was fixed in 1.10.1. I've created a fiddle showing this working properly with 1.10.1 and using 1.8.x with additional CSS to fix the issue. The latter shows that if you can't upgrade to 1.10.1+ right now, you can just include the following CSS:
.ui-helper-clearfix:after {
border-collapse: collapse;
}

Jquery UI breaks layout in ie7 & 8

I developed a good site layout which works like a charm in Webkit and FF based browsers... but in IE 7 and 8 everything get broken up like.
I've never seen so much difference between Safari/Chorme and IE. I tried different DOCTYPEs but there was no difference.
If I remove all the jquery css everything works fine.
You can see it working on [removed]
Can anyone hint me on how to solve this mess?
You have a compatibility issues, I think you need to override the ui-state-default and .ui-state-hover classes on the buyitui.css file to fit IE.
You can use firebug in firefox to go throught the css files.
To overide the css, create one css file and put all the overrides on this file and place it on the bottom of all the css files. Assuming you make sure you are not using inline style sheet.
EDIT:
You need to override this three:
<div class="clear"/>
<div class="separator" style="width: 950px; margin-left: auto; margin-right: auto; float: right;"/>
<div id="pie" style="float: right;">
The Problem seems on the clear class you have above the separator. When you do clear both, all the floating is cleared and the separator is getting up of the page with the height exanding almost all over the page.
Try to change this and you will see the changes:
This could not be the exact solution, but it really points out the problem on your pages.
on the clear class
remove the clear:both; or make it clear:none;
on the separator class
add float:right and margin-right:200px;
on the pie id
add float:right; and margin-right:200px;
the jquery accordion was what was breaking everything, regeneratd and problem solved (just the regular no standars on IE)

Resources