简体   繁体   English

在键盘上隐藏页脚打开 Ionic3

[英]Hide footer on keyboard open Ionic3

I'm trying to hide the footer of my Ionic 3 app when the keyboard is open,当键盘打开时,我试图隐藏我的 Ionic 3 应用程序的页脚,

i've followed the steps found on official documentation and also on this question's accepted answer: Hide tabs on keyboard open我已经按照官方文档中的步骤以及这个问题的公认答案进行了操作: 隐藏键盘上的选项卡打开

I've correctly installed the keyboard plugin and imported it in app.module.ts, i have this code in app.component.ts:我已经正确安装了键盘插件并将其导入到 app.module.ts 中,我在 app.component.ts 中有此代码:

this.platform.ready().then(() => {

  this.keyboard.onKeyboardShow().subscribe(() => {
        document.body.classList.add('keyboard-is-open');
    });

    this.keyboard.onKeyboardHide().subscribe(() => {
        document.body.classList.remove('keyboard-is-open');
    });


});

i've correctly set the css class :我已经正确设置了 css 类:

body.keyboard-is-open .hideElementOnKeyboardShown{
    display: none;        
}

and added this "hideElementOnKeyboardShown" class to the footer, what's happening now is that the footer disappears for few milliseconds (i guess the time that it takes for the keyboard to show up) and then reappears on top of the keyboard, partially hiding some input fields on the page.并将这个“hideElementOnKeyboardShown”类添加到页脚,现在发生的是页脚消失了几毫秒(我猜键盘显示所需的时间)然后重新出现在键盘顶部,部分隐藏了一些输入页面上的字段。

I need to find a way to hide the footer, or just to keep it at the bottom of the page, covered by the keyboard (i've also tried with z-index but it isn't working)我需要找到一种隐藏页脚的方法,或者只是将它保留在页面底部,被键盘覆盖(我也尝试过使用 z-index 但它不起作用)

Hi!嗨!

All you need to do is to add a {hidden} property on you ion-footer and set it according to a 'keyboard is open' method that returns true or false.您需要做的就是在您的 ion-footer 上添加一个 {hidden} 属性,并根据返回 true 或 false 的“键盘已打开”方法对其进行设置。

Example:示例:

<ion-footer [hidden]="keyboard.isOpen()" no-border padding>
 //content
</ion-footer>

Component.html组件.html

<ion-footer [hidden]="isHideFooter"> ....</ion-footer>

Component.ts组件.ts

isHideFooter:boolean = false;

ionViewWillEnter() {

  this.keyboard.onKeyboardShow().subscribe((result)=>{
    this.isHideFooter=true;
  })

  this.keyboard.onKeyboardHide().subscribe((result)=>{
    this.isHideFooter=false;
  })
}

In case your problem is that, footer is moving up when keyboard opens如果您的问题是,当键盘打开时页脚会向上移动

So rather to hide the footer you can make use of所以宁愿隐藏你可以使用的页脚

android:windowSoftInputMode="adjustPan"

put this line in your app/manifests/AndroidManifest.xml inside activity tag that contains your intentfilter action as 'MAIN' and category as 'LAUNCHER'将此行放在您的 app/manifests/AndroidManifest.xml 中的活动标签内,其中包含您的意图过滤器操作为“MAIN”,类别为“LAUNCHER”

if this is your problem it will solve it!如果这是您的问题,它将解决它!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM