在XCODE上使用phonegap进行sencha touch 2 - 索引html未加载app.js

时间:2013-10-20 16:11:05

标签: cordova sencha-touch-2 xcode4.3

我有一个问题。 我在xcode 4.3上使用phonegap 2.0加载我的sencha touch 2。 我看到phonegap调用了我的index.html文件,但后来没有任何反应 - 白屏。 我认为它不会调用app.js启动方法,因为我在第一行和console.log中放了一个警告。

任何人都可以帮我识别问题吗?

的index.html

<!DOCTYPE HTML>

<html manifest="" lang="en-US">
<head>
    <meta charset="UTF-8">
    <title>MyBiluim</title>
    <script type="text/javascript" src="app.js"></script>
     <script src="touch/sencha-touch-all-debug.js"></script>
    <script type="text/javascript" src="cordova-2.0.0.js"></script>
    <link rel="stylesheet" href="touch/resources/css/sencha-touch.css">
    <link rel="stylesheet" href="resources/css/MyBiluim.css">
    <script src="http://maps.google.com/maps/api/js?sensor=true"></script>
    <script src="app/FacebookAPI.js"></script>
    <script src="http://www.parsecdn.com/js/parse-1.2.8.min.js"></script>
    <script src="Server-side/sha512.js" id="sha512"></script>
    <script src="Server-side/GlobalVars.js"></script>
</head>
    <body><script >alert('in index.html');</script></body>
</html>

app.js

/*
 * File: app.js
 *
 * This file was generated by Sencha Architect version 2.2.2.
 * http://www.sencha.com/products/architect/
 *
 * This file requires use of the Sencha Touch 2.1.x library, under independent license.
 * License of Sencha Architect does not include license for Sencha Touch 2.1.x. For more
 * details see http://www.sencha.com/license or contact license@sencha.com.
 *
 * This file will be auto-generated each and everytime you save your project.
 *
 * Do NOT hand edit this file.
 */

//@require @packageOverrides
Ext.Loader.setConfig({
    disableCaching: false,
    paths: {
        Ext: '../src',
        'Ext.device': 'device',
        'MyApp.Facebook': 'app/'
    }
});

Ext.application({

    requires: [
        'Ext.device.Geolocation',
        'Ext.device.Notification',
        'Ext.TitleBar',
        'Ext.data.*',
        'Ext.device.Connection'
    ],
    models: [
        'UserModel',
        'Business',
        'Location',
        'Category',
        'LocalData',
        'BusinessSales',
        'BusinessPhotos',
        'BusinessPhones',
        'BusinessLines',
        'GeneralAction',
        'BusinessUser',
        'SearchSort',
        'RatingBusiness',
        'UserFavoBusiness'
    ],
    stores: [
        'BusinessStore',
        'LocationStore',
        'CategoryStore',
        'LocalStore',
        'BusinessLinesStore',
        'BusinessPhotosStore',
        'BusinessSalesStore',
        'BusinessPhonesStore',
        'GeneralAction',
        'BusinessUserStore',
        'SearchSortStore',
        'BusinessStoreNearByScreen',
        'UserStore',
        'UserFavoBusinessStore',
        'BusinessStoreBusinessScreen'
    ],
    views: [
        'loginformpanel',
        'MyLocScreen',
        'LocateScreen',
        'RatingScreen',
        'SearchList',
        'BusinessScreen',
        'UserActivityScreen',
        'RatingUserList',
        'FirstScreen',
        'fbloginpanel',
        'SearchScreen',
        'MyContainer20',
        'BusinessDataView',
        'BusinessDataItem',
        'MyDataView',
        'RatePlaceScreen',
        'settingpanel'
    ],
    controllers: [
        'Facebook',
        'NearByListControl',
        'BusinessScreenControl',
        'SearchListControl',
        'SearchScreen',
        'RatingControl'
    ],
    name: 'MyApp',

    launch: function() {
        alert('in app.js launch');
        console.log('app launch');                
        //WL.Facebook.initialize('204911179670306');
        //localStorage.serverpath = 'localhost/myprojects/MyBiluim';
        //localStorage.serverpath = 'localhost/elitest_sencha_phonegap - biluim 2/elitest_sencha_phonegap/android/assets/www';
        //localStorage.serverpath = '10.0.2.2:80/elitest_sencha_phonegap - biluim 2/elitest_sencha_phonegap/android/assets/www';
        localStorage.serverpath = 'www.heys.biz/client-side';
        localStorage.user_id =-1;
        console.log(localStorage.serverpath);

        //if the user already did login to the app, automate the login.
        if(localStorage.biluimemail && localStorage.biluimpwd && localStorage.biluimfb)
        {
            var Screen = Ext.ComponentQuery.query('#loginformpanel');
            var loginScreen;

            if(Screen.length===0)//no
            {
                Screen = Ext.create('MyApp.view.loginformpanel', {
                    id: 'loginformpanel'
                });

                loginScreen = Screen;


            }
            else
            {
                loginScreen = Screen[0];
            }


            loginScreen.down('emailfield[id=email1]').setValue(localStorage.biluimemail);
            loginScreen.down('passwordfield[id=password1]').setValue(localStorage.biluimpwd);
            //var controller = MyApp.app.getController( 'MyApp.controller.Facebook');
            //controller.SubmitLoginForm(localStorage.biluimfb,"0");
        }
        Ext.create('MyApp.view.fbloginpanel', {fullscreen: true});
    }

});

appDelegate.m

/*
 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.
 */

//
//  AppDelegate.m
//  HeysApp
//
//  Created by ___FULLUSERNAME___ on ___DATE___.
//  Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//

#import "AppDelegate.h"
#import "MainViewController.h"

#import <Cordova/CDVPlugin.h>
#import <Cordova/CDVURLProtocol.h>


@implementation AppDelegate

@synthesize window, viewController;

- (id) init
{   
    /** If you need to do any extra app-specific initialization, you can do it here
     *  -jm
     **/
    NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 
    [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];

    [CDVURLProtocol registerURLProtocol];

    return [super init];
}

#pragma UIApplicationDelegate implementation

/**
 * This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up)
 */
- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{    
    NSURL* url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
    NSString* invokeString = nil;

    if (url && [url isKindOfClass:[NSURL class]]) {
        invokeString = [url absoluteString];
        NSLog(@"HeysApp launchOptions = %@", url);
    }    

    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
    self.window.autoresizesSubviews = YES;

    CGRect viewBounds = [[UIScreen mainScreen] applicationFrame];

    self.viewController = [[[MainViewController alloc] init] autorelease];
    self.viewController.useSplashScreen = YES;
    self.viewController.wwwFolderName = @"www";
    self.viewController.startPage = @"index.html";
    self.viewController.invokeString = invokeString;
    self.viewController.view.frame = viewBounds;

    // check whether the current orientation is supported: if it is, keep it, rather than forcing a rotation
    BOOL forceStartupRotation = YES;
    UIDeviceOrientation curDevOrientation = [[UIDevice currentDevice] orientation];

    if (UIDeviceOrientationUnknown == curDevOrientation) {
        // UIDevice isn't firing orientation notifications yet… go look at the status bar
        curDevOrientation = (UIDeviceOrientation)[[UIApplication sharedApplication] statusBarOrientation];
    }

    if (UIDeviceOrientationIsValidInterfaceOrientation(curDevOrientation)) {
        for (NSNumber *orient in self.viewController.supportedOrientations) {
            if ([orient intValue] == curDevOrientation) {
                forceStartupRotation = NO;
                break;
            }
        }
    } 

    if (forceStartupRotation) {
        NSLog(@"supportedOrientations: %@", self.viewController.supportedOrientations);
        // The first item in the supportedOrientations array is the start orientation (guaranteed to be at least Portrait)
        UIInterfaceOrientation newOrient = [[self.viewController.supportedOrientations objectAtIndex:0] intValue];
        NSLog(@"AppDelegate forcing status bar to: %d from: %d", newOrient, curDevOrientation);
        [[UIApplication sharedApplication] setStatusBarOrientation:newOrient];
    }

    [self.window addSubview:self.viewController.view];
    [self.window makeKeyAndVisible];

    return YES;
}

// this happens while we are running ( in the background, or from within our own app )
// only valid if HeysApp-Info.plist specifies a protocol to handle
- (BOOL) application:(UIApplication*)application handleOpenURL:(NSURL*)url 
{
    if (!url) { 
        return NO; 
    }

    // calls into javascript global function 'handleOpenURL'
    NSString* jsString = [NSString stringWithFormat:@"handleOpenURL(\"%@\");", url];
    [self.viewController.webView stringByEvaluatingJavaScriptFromString:jsString];

    // all plugins will get the notification, and their handlers will be called 
    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];

    return YES;    
}

- (void) dealloc
{
    [super dealloc];
}

@end

0 个答案:

没有答案