javascript - Ionic iOS 键盘显示问题
问题描述
HTML:
<ion-view ng-controller="EntryController" class="bg-grey">
<ion-content scroll="true" overflow-scroll="true" class="start-page has-footer" has-bouncing="false">
<div>
<input id="txtEntryInput" type="number" inputmode="decimal" pattern="[0-9]*" ng-model="entryInput" ng-
enter="someActionOnEnter()" />
</div>
</ion-content>
</ion-view>
JS:
app.controller("EntryController", function($scope, $timeout, $http){
//this binds the event when *Done* is pressed on keyboard mobile iOS browser
$timeout(function(){
var entryElement = document.getElementById('txtEntryInput');
if(entryElement) {
entryElement.addEventListener('focusout', function (e) {
$scope.someActionOnEnter();
});
}
});
$scope.someActionOnEnter = function(){
//some ajax call dummy
$http({}).then(function(){
//this is not focusing on element and not showing keyboard on mobile safari, on android it is working
$timeout(function(){
$('#txtEntryInput').focus()
});
});
};
});
我想在输入输入后立即显示键盘。它不适用于浏览器。
在离子应用程序中,我使用以下配置:
配置文件
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
来自https://github.com/driftyco/ionic-plugin-keyboard.git的 ionic-plugin-keyboard 2.2.1
为了显示键盘,我使用以下代码:
$timeout(function () {
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.show();
}
}, 100);
任何帮助表示赞赏,我想在输入后立即显示键盘。
解决方案
推荐阅读
- php - Laravel 向 mysql 中插入多个数组
- c# - 为什么 .NET Core 中 Enumerable.Zip() 的 2 参数重载但 .NET Standard 中没有?
- java - 带有 swagger2 的 Java Spring 未启动服务器
- azure - Azure 表存储中插入的新项目不会立即可用
- node.js - discord.js 将参数数据存储在一个名为 + guild id 的文件中
- ember.js - 如何在不经过 JSON 解析的情况下从后端获取文件
- regex - 使用正则表达式提取数据框
- ruby-on-rails - Rails 因 zsh 失败:中止或中止陷阱:6
- macos - 在 macos(PyCharm、GoLand、Android Studio)上的 IDEA 应用程序中,CMD-Period 意外翻译为 ESC
- acumatica - 如何将插入操作添加到移动应用程序的网格行级别?