Cordova / appFramework应用程序在iOS上显示为空白

时间:2014-05-14 03:25:30

标签: ios cordova cordova-3 hybrid-mobile-app appframework

我使用Cordova和appFramework开发了一个非常简单的混合移动应用程序。

index.html看起来像这样

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <!-- WARNING: for iOS 7, remove the width=device-width and
    height=device-height attributes. See https://issues.apache.org
    /jira/browse/CB-4323 -->
    <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/index.css" />

    <link rel="stylesheet" type="text/css" href="css/af/main.css"  />
    <link rel="stylesheet" type="text/css" href="css/af/appframework.css" />
    <link rel="stylesheet" type="text/css" href="css/af/lists.css"  />
    <link rel="stylesheet" type="text/css" href="css/af/forms.css"  />
    <link rel="stylesheet" type="text/css" href="css/af/buttons.css"  />
    <link rel="stylesheet" type="text/css" href="css/af/badges.css"  />      
    <link rel="stylesheet" type="text/css" href="css/af/grid.css"  />

    <link rel="stylesheet" type="text/css" href="css/af/android.css"  />
    <link rel="stylesheet" type="text/css" href="css/af/win8.css"  />
    <link rel="stylesheet" type="text/css" href="css/af/bb.css"  />
    <link rel="stylesheet" type="text/css" href="css/af/ios.css"  />
    <link rel="stylesheet" type="text/css" href="css/af/ios7.css"  />
    <link rel="stylesheet" type="text/css" href="css/af/tizen.css"  />

    <title>Cordova Application</title>
    <script type="text/javascript" charset="utf-8"
    src="js/vendor/appframework.js"></script>
    <script type="text/javascript" charset="utf-8" 
    src="js/vendor/plugins/af.scroller.js"></script>
    <script type="text/javascript" charset="utf-8" 
    src="js/vendor/plugins/af.css3animate.js"></script>

    <script type="text/javascript" charset="utf-8" 
    src="js/vendor/ui/appframework.ui.js"></script>
    <script type="text/javascript" charset="utf-8" 
    src="js/vendor/ui/transitions/fade.js"></script>
    <script type="text/javascript" charset="utf-8" 
    src="js/vendor/ui/transitions/flip.js"></script>
    <script type="text/javascript" charset="utf-8" 
    src="js/vendor/ui/transitions/pop.js"></script>
    <script type="text/javascript" charset="utf-8" 
    src="js/vendor/ui/transitions/slide.js"></script>
    <script type="text/javascript" charset="utf-8" 
    src="js/vendor/ui/transitions/slideDown.js"></script>
    <script type="text/javascript" charset="utf-8" 
    src="js/vendor/ui/transitions/slideUp.js"></script>
    <script type="text/javascript" charset="utf-8" 
    src="js/vendor/plugins/af.slidemenu.js"></script>

    <script>
        $.ui.ready(function () {
            console.log("UI Ready!!!");
        });
        $(document).ready(function() {
            console.log('Document Ready...');
            alert('Document Ready...');
        });
    </script>
</head>
<body>
    <div id="afui">
        <div id="header">
        </div>
        <div id="content">
            <div data-title="Home" class="panel"
                                 id="main" selected="true">
                <span>THIS is the HOME Page!</span>
            </div>
            <div data-title="Second Page" class="panel" id="second">
            </div>
        </div>
        <nav>
            <div class="title">Nav Home</div>
            <ul>
                <li><a class="icon home mini"
                                    href="#main">Home Link</a></li>
                <li><a class="icon mini"
                                    href="#second">Second Link</a></li>
            </ul>
        </nav>
    </div>
    <script type="text/javascript" src="cordova.js"></script>
</body>
</html>

这正确显示,甚至在Safari或Chrome桌面浏览器中打开时,导航也已连线。

但是,如果我在iOS或Android模拟器中运行它,我会看到警告“文档就绪”并在该空白页面之后。不显示主页面板。

以下是我运行模拟器的方法。

 cordova emulate ios
 cordova emulate android

即使我直接从平台版本打开index.html文件,它们也会在桌面浏览器上正确显示。

我对这一切都很陌生,所以我可能会错过这里的步骤。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

你不需要所有碎片的appframework js和css文件,你可以只包含2个css和1个js文件,这里是更新的代码,它在android上作为cordova应用程序,我用 {{3构建了Cordova应用程序}}

<!DOCTYPE html>
<html>
<head>
    <title>XDK</title>
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0;" />

    <link rel="stylesheet" type="text/css" href="css/af.ui.css" />
    <link rel="stylesheet" type="text/css" href="css/icons.css" />
    <script type="text/javascript" charset="utf-8" src="js/appframework.ui.min.js"></script>

    <script>
        $.ui.ready(function () {
            console.log("UI Ready!!!");
        });
        $(document).ready(function() {
            console.log('Document Ready...');
            alert('Document Ready...');
        });
    </script>
</head>
<body>
    <div id="afui">
        <div id="header">
        </div>
        <div id="content">
            <div title="Home" class="panel" id="main" selected="true">
                <span>THIS is the HOME Page!</span>
            </div>
            <div title="Second Page" class="panel" id="second">
            </div>
        </div>
        <nav>
            <div class="title">Nav Home</div>
            <ul class="list">
                <li><a class="icon home mini" href="#main">Home Link</a></li>
                <li><a class="icon mini" href="#second">Second Link</a></li>
            </ul>
        </nav>
    </div>
    <script type="text/javascript" src="cordova.js"></script>
</body>
</html>