2016-01-06 137 views
1

我想在用戶單擊按鈕時顯示iOS鍵盤。
這裏是我的HTML代碼:Ionic iOS鍵盤

<div ng-controller="KbCtrl as ctrl"> 
    <button ng-click=(ctrl.showKeyboard())></button> 
</div> 

而且我的控制器:

angular.controller('KbCtrl', function() { 
    var self = this; 
    this.showKeyboard = function() { 
     cordova.plugins.Keyboard.show(); 
    } 
}) 

所以,當按鈕它將運行showKeyboard在我的控制器()函數的用戶點擊。
但沒有出現,我得到我的SYSTEM.LOG此消息:

Showing keyboard not supported in iOS due to platform limitations. 

如何解決這一問題?我真的需要我的應用程序中的這個功能。
是否有另一種方式或另一個插件在iOS上運行良好?

回答

0

您可以使用Browser-API來聚焦輸入元素。這會自動打開鍵盤。

var first = document.querySelectorAll('#myInputField')[0]; 
    if (first) { 
    first.focus(); 
    }