如何检测Cordova WebView何时完全完成加载? [英] How to detect when a Cordova WebView completely finished loading?
本文介绍了如何检测Cordova WebView何时完全完成加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经嵌入了cordova Webview. 然后我从本地调用了javascript,如下所示.
I have embedded cordova webview. and then I have called javascript from native like below.
[self.viewView stringByEvaluatingJavaScriptFromString: jscode];
但由于未加载JS文件而无法执行.
but it is not performing because JS files were not loaded.
如何检测Cordova WebView何时完全完成加载?
How to detect when a Cordova WebView completely finished loading?
推荐答案
加载html时,将发布通知. 您可以使用以下代码收听它:
When the html is loaded, a notification is posted. You can listen to it with this code:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pageDidLoad) name:CDVPageDidLoadNotification object:self.webView];
然后,在收到通知时,将调用pageDidLoad方法,将您的代码放在此处
Then, when the notification is received, the pageDidLoad method will be called, put your code there
- (void)pageDidLoad
{
NSString * jscode = @"some js code here";
[self.viewView stringByEvaluatingJavaScriptFromString: jscode];
}
这篇关于如何检测Cordova WebView何时完全完成加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文