4

私のアイデアは、アプリのビジネス ロジックに Phonegap を使用することですが、ネイティブ トランジションを使用することです。したがって、すべての UIViewController に CDVWebView が必要です。これは通常の UIWebview では問題なく動作しますが、TabBar などに複数の CDVViewController を使用すると、deviceReady イベントは最初の CDVWebView に対してのみ発生します。

アプリデリゲートで行うことは次のとおりです。

- (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(@"NativeNavigationTest launchOptions = %@", url);
}    
NSLog(@"invokeString = %@", invokeString);
CGRect screenBounds = [[UIScreen mainScreen] bounds];
self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
self.window.autoresizesSubviews = YES;

CGRect viewBounds = [[UIScreen mainScreen] applicationFrame];


//4 ViewController, each one inherits from CDVViewController

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;

self.secondController = [[[SecondController alloc] init] autorelease];
self.secondController.useSplashScreen = YES;
self.secondController.wwwFolderName = @"www";
self.secondController.startPage = @"second.html";
self.secondController.invokeString = invokeString;
self.secondController.view.frame = viewBounds;


self.thirdController = [[[ThirdController alloc] init] autorelease];
self.thirdController.useSplashScreen = YES;
self.thirdController.wwwFolderName = @"www";
self.thirdController.startPage = @"third.html";
self.thirdController.invokeString = invokeString;
self.thirdController.view.frame = viewBounds;

self.fourthController = [[[FourthController alloc] init] autorelease];
self.fourthController.useSplashScreen = YES;
self.fourthController.wwwFolderName = @"www";
self.fourthController.startPage = @"fourth.html";
self.fourthController.invokeString = invokeString;
self.fourthController.view.frame = viewBounds;


//add them in a native ViewController environment like a Tabbar

self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController, secondController, thirdController, fourthController, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;

}

これは、最初の ViewController を除く各 ViewController で発生するエラーです。

Error: executing module function 'setInfo' in module 'cordova/plugin/ios/device'. Have you included the iOS version of the cordova-1.9.0.js 

ERROR: Attempting to call cordova.exec() before 'deviceready'. Ignoring.

もちろん、HTML ファイルで cordova-1.9.0 を参照しています。Cordova は複数の WebView を使用するようには設計されていないと思いますが、これを変更する方法を知っている人はいますか?

4

2 に答える 2

1

これは Cordovaの競合状態であることを確認しました。この問題は 2.4.0 で修正されています。

于 2013-03-11T10:52:16.337 に答える
1

答えはCordova WebViewです。ネイティブ アプリケーションに組み込まれるように設計されています。

編集

複数の Cordova Webview を使用すると、同じエラーが発生します。プロジェクトに Phonegap を利用した Webview を 1 つしか配置できない場合、それが何を意味するのかわかりません。

于 2012-10-31T08:07:01.270 に答える