2012-11-15 37 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