首页 > 解决方案 > 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);

任何帮助表示赞赏,我想在输入后立即显示键盘。

标签: javascriptangularjsiphoneionic-frameworkmobile-safari

解决方案


推荐阅读