Phonegap / Cordova与多个CDVViewController [英] Phonegap/Cordova with Multiple CDVViewController
问题描述
我的想法是使用Phonegap为我的应用程序的业务逻辑,但使用本机过渡。所以我需要CDVWebView在每个UIViewController。这与正常的UIWebviews工作正常,但如果我使用多个CDVViewControllers例如。一个TabBar,deviceReady事件只会针对第一个CDVWebView触发。
my Idea is to use Phonegap for the business logic of my app, but use native transitions. So I need CDVWebView in every UIViewController. This works fine with normal UIWebviews, but if I use multiple CDVViewControllers for e.g. a TabBar, the deviceReady event only fires for the first CDVWebView.
这是我在应用程序代表中执行的操作:
Here is what I do in the App Delegate:
- (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;
}
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,
Of course I refer to cordova-1.9.0 in my HTML files, I think Cordova was not designed to use multiple WebViews of it, but does anybody know how to change this?
推荐答案
我确认这是一个 Cordova的种族条件 - 问题已修正为2.4.0。
I confirmed this as a race condition in Cordova - the issue is fixed as of 2.4.0.
这篇关于Phonegap / Cordova与多个CDVViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!