0

Hey Guys ios で deviceready を起動する際に問題がありますが、コードは adnroid エミュレーターで検出されるだけで、何が問題なのかわかりません。私はreadl androidデバイスでは試しませんでしたが、エミュレーターは正常に動作しますが、iPhone 5で試してみましたが、デバイスの準備ができているとは言えません.別の質問があります.コルドバには、プラットフォームごとに異なるjsファイルがありますか?

var deviceReadyDeferred = $.Deferred();
var jqmReadyDeferred = $.Deferred();

document.addEventListener("deviceReady", deviceReady, false);
document.addEventListener("resume", deviceResume, false);

function deviceResume() {
doWhenBothFrameworksLoaded();
}

function deviceReady() {
deviceReadyDeferred.resolve();
}

$(document).one("mobileinit", function() {
jqmReadyDeferred.resolve();     
});

$.when(deviceReadyDeferred, jqmReadyDeferred).then(
doWhenBothFrameworksLoaded);

function doWhenBothFrameworksLoaded() {
var networkState = navigator.connection.type;

var states = {};
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.CELL] = 'Cell generic connection';
states[Connection.NONE] = 'No network connection';

if (networkState == Connection.NONE)
    alert('You have to be connected to the internet in order to use this app.');
else {
    setTimeout(function(){
        $.mobile.changePage("deals.html", {
            transition : "pop",
            reverse : false,
            changeHash : false
        });
    },1000);
}
}


<!DOCTYPE HTML>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>PhoneGap</title>

    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
    <script type="text/javascript" charset="utf-8" src="cordova-2.6.0.js"></script>
    <script type="text/javascript" charset="utf-8" src="PushNotification.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/jquery.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="controller/index.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/jqueryMobile.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/handlebars.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/handleHelpers.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/jquery.timeago.js"></script>


    <link rel="stylesheet" href="css/jqm.css" charset="utf-8" />
    <link rel="stylesheet" href="css/style.css" charset="utf-8" />
</head>
<body>
    <div class="container splash" data-role="page" id="index">
        <img src="img/logo.png" />
    </div>
</body>
</html>
4

2 に答える 2

0

jquery mobile と一緒に phonegap を使用するには、次のように使用する必要があります。

$(document).one("mobileinit", function() {
    $.support.cors = true;
    $.mobile.allowCrossDomainPages = true;
    jqmReadyDeferred.resolve();     
});
于 2013-05-02T13:50:43.003 に答える