【问题标题】:phonegap - webViewDidFinishLoad not getting calledphonegap - webViewDidFinishLoad 没有被调用
【发布时间】:2012-10-01 17:34:45
【问题描述】:

我正在使用 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 ];
}

【问题讨论】:

    标签: iphone ios cordova uiwebview


    【解决方案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/%3C20120716205424.998B414A2D@tyr.zones.apache.org%3E

    【讨论】:

      猜你喜欢
      • 2011-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多