Ho problemi con PhoneGap in iPhone con gli eventi. L'app sta funzionando abbastanza bene nel mio dispositivo Android, ma sul mio iPhone non fa nulla. Ad esempio, un semplice codice come questo:Gli eventi di PhoneGap non funzionano in iphone
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0;" />
<meta charset="utf-8">
<title>WayAcross Mobile Application</title>
<link rel="stylesheet" href="css/jquery.css" />
<link rel="stylesheet" href="css/screen.css" />
<link rel="stylesheet" href="css/login.css" />
<script type="text/javascript" charset="utf-8" src="jquery/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="jquery/jquery.mobile.js"></script>
<script type="text/javascript" charset="UTF-8" src="javascript/mainJavascript.js"></script>
<script type="text/javascript" charset="utf-8">
// Call onDeviceReady when PhoneGap is loaded.
//
// At this point, the document has loaded but phonegap.js has not.
// When PhoneGap is loaded and talking with the native device,
// it will call the event `deviceready`.
//
function onLoad(){
document.addEventListener("deviceready", onDeviceReady, false);
}
// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
//
function onDeviceReady() {
// Now safe to use the PhoneGap API
alert('ready');
}
</script>
<script type="text/javascript" charset="utf-8" src="javascript/phonegap.js"></script>
</head>
<body onload="onLoad()">
(questo è un esempio di codice che non funziona con iPhone e funziona con Android).
Penso che sia un problema con gli eventi, ma non ne sono sicuro. Anche gli esempi di codice nei documenti PhoneGap non funzionano. Il mio ambiente è:
- Mac OSX 10.7.1
- Xcode 4.1
- PhoneGap 1.1
- jQuery Mobile 1.0RC L'unica cosa che mi mostra è questa: http://cl.ly/0h462Y2D2F0J0B1B0q1M
Grazie in anticipo.
Saluti,
Elkas
A proposito, ho installato OSX Lion 10.7.2 e Xcode 4.2 ora. Anche in IOS5 non funziona. Questo mi sta facendo impazzire !!! Anche con questo semplice codice non funziona.
<!DOCTYPE html>
<html>
<head>
<title>PhoneGap Device Ready Example</title>
<script type="text/javascript" charset="utf-8">
// Call onDeviceReady when PhoneGap is loaded.
//
// At this point, the document has loaded but phonegap.js has not.
// When PhoneGap is loaded and talking with the native device,
// it will call the event `deviceready`.
//
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
//
function onDeviceReady() {
alert('Hello World');
}
</script>
<script type="text/javascript" charset="utf-8" src="javascript/phonegap.js"</script>
</head>
<body>
</body>
</html>
Tutto sembra a posto, provare a registrare le cose usando alert() per scoprire dove non funziona. – sciritai
Prova anche quello. se metto onload = "onDeviceReady()" nel tag body o in un'altra funzione, viene visualizzato l'avviso ma gli "eventi" di tipo "PhoneGap" continuano a non funzionare. = ( – Elkas
jQuery mobile deve essere aggiunto * dopo * script personalizzati. – Walf