用Angular5.2.9 + Ionic3.2 + Ionic Native 4.5.3 + Cordova8.0 + Cordova-ios 4.5.4 + Cordova-plugin-inappbrowser 2.0.3-dev 做了一個帶有InAppBrowser的APP,在APP中訪問如下html,運行后效果 以及 代碼如下:
testsoftkeyboard3.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script language="javascript">
var objInput1=null;
var objInput2=null;
function initLoad()
{
objInput1=document.getElementById("input1");
objInput2=document.getElementById("input2");
}
function onBlur(event)
{
if(event.target.value == 'abc')
{
event.target.style.backgroundColor="#ffffff";
return true;
}
//這里如果不用setTimeout來執(zhí)行alert,那么當采用下面描述的方式2時,整個InAppBrowser會死掉,不想應任何操作
setTimeout(function () {
alert('please input abc');
//objInput1.focus();
//objInput1.click();
}, 0);
event.target.style.backgroundColor = "#ff0000";
event.target.focus();
event.target.click();
return false;
}
</script>
</head>
<body onload="javascript:initLoad()">
input1:<input type="text" id="input1" onblur="javascript:onBlur(event);"/>     -     
input2:<input type="text" id="input2"/>
<br/>
</body>
</html>
上面的代碼主要是為了實現(xiàn)以下效果:
第1步、當焦點在input1中時,iPad自動顯示軟鍵盤(代碼上沒有特意控制,應該是iOS 默認的功能,焦點在輸入框時會自動彈出軟鍵盤)
第2步、當在input1中輸入內(nèi)容后,在失去焦點時進行輸入檢查(在onblur事件中實現(xiàn)),如果發(fā)現(xiàn)輸入的內(nèi)容不為abc,則彈出alert警告
第3步、同時將input1的背景色改為紅色,并且讓焦點回到input1,并自動顯示出軟鍵盤
目前遇到的問題主要出在上面第2步與第3步,讓input1失去焦點有兩種方式:
方式1、點擊input2
方式2、按軟鍵盤最右下角的按鈕將鍵盤收起
目前按方式1來操作,沒有問題,第3步能按照預期的效果呈現(xiàn)。
但是當采用方式2時,當通過調(diào)用focus()方法讓input1獲得焦點后,軟鍵盤會閃現(xiàn)(出現(xiàn)后,又馬上消失),試了很多方法都能保持軟鍵盤一直出現(xiàn),調(diào)查了2,3天都沒搞定,不知道是否需要修改InAppBrowser的Objective-C代碼,麻煩大家?guī)兔匆幌聭撛鯓咏鉀Q?非常感謝!
北大青鳥APTECH成立于1999年。依托北京大學優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
北大青鳥中博軟件學院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學院和江蘇省首批服務外包人才培訓基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術與教育服務機構,發(fā)展為教育服務業(yè)的綜合性企業(yè)集團,成為集合面授教學培訓、網(wǎng)
達內(nèi)教育集團成立于2002年,是一家由留學海歸創(chuàng)辦的高端職業(yè)教育培訓機構,是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
浪潮集團項目經(jīng)理。精通Java與.NET 技術, 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗,技術功底深厚。 授課風格 授課風格清新自然、條理清晰、主次分明、重點難點突出、引人入勝。
曾工作于聯(lián)想擔任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍懿科技有限責任公司從事總經(jīng)理職務負責iOS教學及管理工作。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應用開發(fā)經(jīng)驗。曾經(jīng)歷任德國Software AG 技術顧問,美國Dachieve 系統(tǒng)架構師,美國AngelEngineers Inc. 系統(tǒng)架構師。