ios - ionic3 允许键盘将 View 向上推

标签 ios keyboard ionic3 cordova-plugins

我使用的是 Ionic 版本 3.9.2

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

enter image description here

不希望键盘覆盖我的页脚

enter image description here

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

最佳答案

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

尝试进行以下更改,看看它是否符合您的要求。您需要调整键盘高度和缓动才能正常工作

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/

相关文章:

ios - NotificationService Extension (ios) 未被调用

xcode - 更改键盘的字体

sqlite - 出现错误 ionic3 项目中的类型 'openDatabase' 上不存在属性 'SQLite'?

firebase - 无法读取 Ionic 中未定义错误的属性 'manifest'

typescript - 将数据从 firebase 函数返回到应用程序

ios - 如何在第一行文本中心的 Y 轴上对齐两个 UILabel

iOS 应用程序因没有堆栈跟踪的未捕获异常而终止 (Swift)

python - 捕获键盘不允许改变焦点

ios - 如何隐藏IOS键盘上的返回键

ios - 如何在 Swift 中对绘图进行动画处理,同时更改 UIImageView 比例?