2012-11-15 40 views
2

我正在嘗試第一次獲得JQuery mobile(1.2.0)與Phonegap(2.2.0)的XCode一起使用。 Xcode的/ PhoneGap的安裝工程 - 它已經根據XCode 4.5.1,Cordova 2.2,jquery mobile

http://docs.phonegap.com/en/2.2.0/guide_getting-started_ios_index.md.html#Getting%20Started%20with%20iOS

然後我添加了jQuery Mobile的CSS和JS到www/JS廣告WWW /該項目的CSS已經設置,並有一個簡單的索引。 HTML

<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
     <meta name="format-detection" content="telephone=no" /> 
     <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> 
     <link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.2.0.css"/> 
     <link rel="stylesheet" type="text/css" href="css/jquery.mobile.structure-1.2.0.css"/> 

     <title>Test of jquery mobile</title> 
    </head> 
    <script type="text/javascript" src="cordova-2.2.0.js"></script> 
    <script type="text/javascript" src="js/index.js"></script> 
    <script type="text/javascript" src="js/jquery.mobile-1.2.0.js"></script> 
    <script type="text/javascript" src="js/jquery-1.8.2.js"></script> 


     <body> 
      <div data-role="page" id="liveListPage"> 
       <div data-role="header" data-position="fixed" data-theme="a" > 
        <h1>Header</h1> 
       </div> 

       <div data-role="footer" data-position="fixed" data-theme="a" > 
        <h1>Footer</h1> 
       </div> 
      </div> 


     </body> 
    </html> 

但推運行時 - 它建立正常,但jQuery Mobile的似乎沒有進入行動在所有 - 我只是得到H1「頭」和「尾」,沒有固定的位置,並沒有主題。 我的計劃是/ iPhone 6.0模擬器。

我在做什麼錯?日誌窗口中沒有錯誤。

親切的問候

託本

+0

是在'www'目錄這個HTML文件?另外,我非常確定你的網站的根目錄應該位於:'/ assets/www /'(對於iOS而言,它不同於Android?)。 – Jasper

+0

@Jasper如果我把它放在'www'文件夾中的同一個地方,那麼這就是文檔所說的 – ryanc1256

+0

我也注意到你的腳本不在'head'或'body'中,他們真的應該在'頭' – ryanc1256

回答

0

我不是很確定這是否是問題,但我注意到,你的腳本是不是,他們應該在任何一個這樣我總是把它們放在頭上。所以這是我會做的

<!DOCTYPE html> 
    <html> 
     <head> 
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
      <meta name="format-detection" content="telephone=no" /> 
      <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> 
      <link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.2.0.css"/> 
      <link rel="stylesheet" type="text/css" href="css/jquery.mobile.structure-1.2.0.css"/> 

      <title>Test of jquery mobile</title> 

      <script type="text/javascript" src="cordova-2.2.0.js"></script>    
      <script type="text/javascript" src="js/jquery.mobile-1.2.0.js"></script> 
      <script type="text/javascript" src="js/jquery-1.8.2.js"></script> 
      <script type="text/javascript" src="js/index.js"></script> <!--your script--> 


     </head> 
      <body> 
       <div data-role="page" id="liveListPage"> 
        <div data-role="header" data-position="fixed" data-theme="a" > 
         <h1>Header</h1> 
        </div> 

        <div data-role="footer" data-position="fixed" data-theme="a" > 
         <h1>Footer</h1> 
        </div> 
       </div> 


      </body> 
     </html> 

編輯::我也注意到了以後有人指出了這一點,你的腳本文件是jQuery的文件上面,所以它不會註冊jQuery庫,所以我會移動您index.js文件下來了一點,所以它的jQuery的下面庫文件

+0

感謝您的答覆。是的,js應該在頭 - 我的錯誤 - 但它似乎沒有改變任何東西。 –

0

有幾個可能的原因在這裏:

  • 構建實際上不是最新的 - Xcode中並不總能檢測到變化網絡文件,所以當你在設備上運行時,你會看到一個較舊的版本。乾淨通常修復這一個。

  • 該鏈接有點不對 - 通常這是一個套管問題,與桌面操作系統不同,iOS區分大小寫。如果您將Safari瀏覽器Web檢查器附加到您的應用程序,您可以看到哪些文件未加載。

  • 該鏈接是完全錯誤的 - 在桌面瀏覽器中打開時,html的工作是否正常?

0

更改腳本文件的順序。我也注意到你沒有用jqm加載css文件。因此你可以先從jquery網站加載。加載js和css文件的順序非常重要。

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /> 
<script type="text/javascript" src="js/jquery-1.8.2.js"></script> 
<script type="text/javascript" src="js/jquery.mobile-1.2.0.js"></script> 
<script type="text/javascript" src="cordova-2.2.0.js"></script> 
<script type="text/javascript" src="js/index.js"></script> 
+0

非常感謝 - 就是這樣 - 順序 - 好的 –

+0

沒問題。我很高興它幫助你。請幫助標記爲已回答:) – Dilberted