我不能用这个最简单的AppMobi.contacts.chooseContact()示例来运行。它适用于XDK,但之后不适用于iPhone 4s的应用实验室,我尝试使用旧的Kindle Fire,在选择一两个联系人后,它会崩溃app-lab应用程序。当您取消正确选择联系人时,它会处理,但如果您选择一个,则事件监听器似乎永远不会被调用。
我也在为iPhone编译的本机应用程序中运行它并遇到同样的问题。这是我用来最低限度地重现问题的代码,我在Windows上运行XDK,在app-lab上使用Test Anywhere运行iPhone和Kindle Fire,它显示了下面描述的相同问题。代码包含在下面。我知道我可能正在做一些非常愚蠢的事情而且看不到它,但我无法弄明白。谢谢。
<!DOCTYPE html><!--HTML5 doctype-->
<html>
<head>
<title>Your New Application</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<style type="text/css">
/* Prevent copy paste for all elements except text fields */
* { -webkit-user-select:none; -webkit-tap-highlight-color:rgba(255, 255, 255, 0); }
input, textarea { -webkit-user-select:text; }
/* Set up the page with a default background image */
body {
background-color:#fff;
color:#000;
font-family:Arial;
font-size:48pt;
margin:0px;padding:0px;
background-image:url('images/background.jpg');
}
</style>
<script type="text/javascript" charset="utf-8" src="_appMobi/appmobi_local_bootstrap.js"></script>
<script type="text/javascript" charset="utf-8" src="http://localhost:58888/_appMobi/xhr.js"></script>
<script type="text/javascript">
/* This function runs once the page is loaded, but appMobi is not yet active */
var init = function(){
};
window.addEventListener("load",init,false);
/* This code prevents users from dragging the page */
var preventDefaultScroll = function(event) {
event.preventDefault();
window.scroll(0,0);
return false;
};
document.addEventListener('touchmove', preventDefaultScroll, false);
/* This code is used to run as soon as appMobi activates */
var onDeviceReady=function(){
//Size the display to 768px by 1024px
AppMobi.display.useViewport(768,1024);
//hide splash screen
AppMobi.device.hideSplashScreen();
document.addEventListener('appMobi.contacts.choose', onChooseContact);
document.addEventListener('appMobi.contacts.busy', onChooseContactBusy);
// runs right away more or less.
AppMobi.contacts.chooseContact();
};
document.addEventListener("appMobi.device.ready",onDeviceReady,false);
function onChooseContact(evt)
{
if (evt.success == true)
{
alert("Choose Contact Success");
//AppMobi.contacts.editContact(evt.contactid);
}
else if (evt.cancelled == true)
{
alert("Choose Contact Cancelled");
} else {
alert("Huh, how did it get here?");
}
}
function onChooseContactBusy()
{
alert('got in OnChooseContactBusy');
}
</script>
</head>
<body>
<a class="button"
onclick="AppMobi.contacts.chooseContact();" >Click Here to Choose Contact</a>
<br />
</body>
</html>