当您升级到 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-店铺/
#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/%3C20120716205424.998B414A2D@tyr.zones.apache.org%3E