当使用phonegap ios时,kendo ui mobile会挂起

时间:2013-04-12 07:11:14

标签: cordova kendo-ui kendo-mobile

我正在使用新发布的kendoui 2013,phonegap 2.6.0,ios emulator 6.1和iphone 4s(ios 6.1)。

我尝试了两种方法: 1)使用phonegap生成的index.html并手动添加kendoui css和javascript。 2)写一个简单的kendoui index.html,没有phonegap的javascript。

两种方式都会挂在开始屏幕上(尚未显示index.html)。但是如果我删除了以下代码,它就不会挂起并显示index.html。

var app = new kendo.mobile.Application();

然后我在代码下面添加一个警告:

var app = new kendo.mobile.Application();
alert("ddddd");

警报将显示在开始屏幕上,但它仍会在开始屏幕上挂起,并且不会显示index.html。

似乎kendoui初始函数中存在一些异步任务,无法在设备上完成。

index.html的源代码:

<!DOCTYPE html>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
-->
<html>
    <head>
        <meta 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/index.css" /> -->
        <link href="1/css/kendo.mobile.all.min.css" rel="stylesheet" />
        <title>Hello World</title>
    </head>
    <body>
        <div data-role="view" id="home">
            <header data-role="header">
                <div data-role="navbar">
                    dddd
                </div>
            </header>
        </div>
        <script type="text/javascript" src="cordova-2.6.0.js"></script>
        <script src="1/js/jquery.min.js"></script>
        <script src="1/js/kendo.all.min.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script type="text/javascript">
            app.initialize();
            var app = new kendo.mobile.Application();
        </script>
    </body>
</html>

有任何解决此问题的建议吗?

2 个答案:

答案 0 :(得分:4)

除了删除app.initialize()之外,还需要移动var app = new kendo.mobile.Application();初始化调用PhoneGap的deviceready事件。

<script>

    document.addEventListener("deviceready", onDeviceReady, false);

    function onDeviceReady() {

        // Now safe to use the Cordova API
        var app = new kendo.mobile.Application();
    }

</script>

答案 1 :(得分:1)

您尝试在分配之前使用app的方法。此外,在Kendo UI Mobile的应用程序中没有这样的方法。只需删除app.initialize()行,您的应用就可能正常运行。