gpt4 book ai didi

iphone - phonegap - webViewDidFinishLoad 没有被调用

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:24:07 25 4
gpt4 key购买 nike

我正在使用 Phonegap2.1。我的 AppDelegate.m 文件中有 webViewDidFinishLoad 方法。它曾经在以前的 phonegap 版本中被自己调用。现在,它根本不会被调用。我需要将委托(delegate)分配到某个地方吗?

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

最佳答案

当您升级到 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

关于iphone - phonegap - webViewDidFinishLoad 没有被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12678147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com