0

我无法以这种最简单的 AppMobi.contacts.chooseContact() 示例工作。它可以在 XDK 中运行,但不适用于 iPhone 4s 的 app-lab,我在旧的 Kindle Fire 上进行了尝试,它在选择一两个联系人后崩溃了 app-lab 应用程序。它在您正确取消选择联系人时处理,但如果您选择一个,则事件侦听器似乎永远不会被调用。

我还在为 iPhone 编译的本机应用程序中运行它,并遇到同样的问题。这是我用来最小化重现问题的代码,我在 Windows 上的 XDK 以及 iPhone 和 Kindle Fire 上使用 App-lab 上的 Test Anywhere 运行,它表现出与下面描述的相同问题。代码包含在下面。我知道我可能正在做一些非常愚蠢的事情,只是看不到它,但我无法弄清楚。谢谢你。

<!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>
4

0 回答 0