如题, 使用div作为输入框,可以实现自增长并可控显示的行数,但是也带来了一个问题:
ios上键盘弹出并不会像Input那样自动顶起页面使键盘不覆盖页面内容(安卓没有这问题).
试了很多方案, 回过头发现了一个很简单的方法:
<ion-content id="content-area">
//你的内容
</ion-content>
var elementContent = document.getElementById("content-area");
//键盘弹出
window.addEventListener("native.keyboardshow", function (e) {
if(ionic.Platform.isIOS()){
elementContent.style.marginBottom = e.keyboardHeight + 'px';
$ionicScrollDelegate.resize();
$ionicScrollDelegate.scrollBottom();
}
});
window.addEventListener('native.keyboardhide', function (e) {
if(ionic.Platform.isIOS()){
elementContent.style.marginBottom = 0;
$ionicScrollDelegate.resize();
$ionicScrollDelegate.scrollBottom();
}
});
很简单.效果也不错.比那些算高度来调节样式方便很多!


best wishes~~~
网友评论