首页 文章

ionic3允许键盘向上推视图

提问于
浏览
2

我正在使用Ionic ver 3.9.2

我想在iOS上推送视图,这样我的页脚就不会隐藏了 .

enter image description here

不希望键盘覆盖我的页脚

enter image description here

在Android上,我可以使用android:windowSoftInputMode = "adjustResize",这神奇地缩小了视图 . 有没有办法实现这个目标?
enter image description here

1 回答

  • 3

    您可以使用Ionic Keyboard PluginonKeyboardShow()onKeyboardHide() 来了解何时调整屏幕大小以排除键盘 .

    尝试进行以下更改,看看它是否符合您的要求 . 您将需要调整keyboard_height和缓动以正确地使其工作

    app.html

    <ion-nav .... [style.height]="nav_style"></ion-nav>
    

    app.component.ts

    keyboard_height: number = 200;
    nav_style: string = null;
    
    constructor(private keyboard: Keyboard, private platform: Platform, ...){
        if(this.platform.is('ios')){
            this.keyboard.onKeyboardShow(() => {
                this.nav_style = 'calc(100%-' + this.keyboard_height + 'px)';
            });
            this.keyboard.onKeyboardHide(() => {
                this.nav_style = null;
            });
        }
    }
    

    app.scss

    ion-nav{
        transition: height 0.2s ease-out
    }
    

相关问题