OGeek|极客世界-中国程序员成长平台

标题: ios - ionic3 允许键盘向上推 View [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 14:40
标题: ios - ionic3 允许键盘向上推 View

我使用的是 Ionic 版本 3.9.2

我想在 iOS 上将 View 向上推,这样我的页脚就不会被隐藏。

enter image description here

不想让键盘盖住我的页脚

enter image description here

在 Android 上,我可以使用 android:windowSoftInputMode="adjustResize"来神奇地缩小 View 。有什么办法可以做到这一点? enter image description here



Best Answer-推荐答案


您可以使用 Ionic Keyboard PluginonKeyboardShow()onKeyboardHide()知道何时调整屏幕大小以排除键盘。

尝试进行以下更改,看看它是否符合您的要求。您需要调整 keyboard_height 和 easing 才能正常工作

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
}

关于ios - ionic3 允许键盘向上推 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50635830/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4