2012-10-01 135 views
3

我正在使用Phonegap2.1。我的AppDelegate.m文件中有webViewDidFinishLoad方法。它曾經在以前的phonegap版本中被自己調用。現在,它根本不會被調用。我需要在某處分配委託嗎?phonegap - webViewDidFinishLoad沒有被調用

- (void)webViewDidFinishLoad:(UIWebView *)theWebView 
{ 
if(self.invokeString) 
{ 
    // this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready 
    NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString]; 
    [theWebView stringByEvaluatingJavaScriptFromString:jsString]; 
} 
// Black base color for background matches the native apps 
theWebView.backgroundColor = [UIColor blackColor]; 

return [ self.viewController webViewDidFinishLoad:theWebView ]; 
} 
+0

請參閱答案 – iOSAndroidWindowsMobileAppsDev

回答

1

當您升級到2.1.0時,建議您註銷掉所有該部分,因爲它已被棄用。當你使用cordova 2.1.0時,你提供的代碼實際上並不能幫助你,所以如果你註釋掉它,你的應用程序應該工作得很好。

http://iphonedevlog.wordpress.com/2012/09/24/phonegap-2-1-0-in-mac-os-x-mountain-lion-10-8-from-download-to-ios-app-store/

#pragma UIWebDelegate implementation 
    /* 
    - (void) webViewDidFinishLoad:(UIWebView*) theWebView 
    { 
    // only valid if ___PROJECTNAME__-Info.plist specifies a protocol to handle 
    if (self.invokeString) 
    { 
    // this is passed before the deviceready event is fired, so you can access it in js when you receive  deviceready 
    NSLog(@"DEPRECATED: window.invokeString - use the window.handleOpenURL(url) function instead, which is always called when the app is launched through a custom scheme url."); 
    NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString]; 
    [theWebView stringByEvaluatingJavaScriptFromString:jsString]; 
    } 

    // Black base color for background matches the native apps 
    theWebView.backgroundColor = [UIColor blackColor]; 

    return [super webViewDidFinishLoad:theWebView]; 
    }*/ 

離開本節註釋掉給出了這樣的警告:

Classes/MainViewController.m:133:11: 'invokeString' is deprecated 
Classes/MainViewController.m:137:86: 'invokeString' is deprecated 

你的應用程序將運行正常僅是不理想的是釋放有警告的產品。

除非你故意不把你的代碼,全世界都看到

[CB-853]棄用window.invokeString - 使用window.handleOpenURL(url)代替

http://mail-archives.apache.org/mod_mbox/incubator-callback-commits/201207.mbox/%[email protected]%3E

相關問題