2012-10-26 240 views
4

我的想法是使用Phonegap的應用程序的業務邏輯,但使用本機轉換。所以我需要在每個UIViewController中使用CDVWebView。這與正常的UIWebviews正常工作,但如果我使用多個CDVViewControllers例如一個TabBar,deviceReady事件只會觸發第一個CDVWebView。Phonegap /科爾多瓦與多個CDVViewController

這是我在App代表做:

- (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. 

當然我指的是科爾多瓦-1.9.0在我的HTML文件,我認爲科爾多瓦沒有被設計爲使用它的多個網頁視圖,但沒有任何人知道如何改變這個?

+0

我相信這是Cordova中的一個錯誤,並且已經在他們的問題跟蹤器中報告了它:https://issues.apache.org/jira/browse/CB-2271 –

回答

1

答案是Cordova WebView。設計用於嵌入本地應用程序。

編輯

與多個科爾多瓦網頁視圖,它具有相同的錯誤。當你仍然只能在你的項目中放置一個單一的基於Phonegap的Webview時,我不知道它有什麼意義。