3

Phonegap2.1 を使用しています。AppDelegate.m ファイルに webViewDidFinishLoad メソッドがあります。以前の phonegap バージョンでは、独自に呼び出されていました。今、それはまったく呼び出されません。デリゲートをどこかに割り当てる必要がありますか?

- (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 ];
}
4

1 に答える 1

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-お店/

    #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

于 2012-12-21T10:35:53.823 に答える