WebView完全加载页面后,有什么办法让我运行一些代码?
如果有帮助,这是我用来在视图中打开网页的代码。
//Load URL Into WebView
NSString *urlAddress = @"http://example.com";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[[_listenupwebkit mainFrame] loadRequest:requestObj];
我的.m文件
- (IBAction)SignInButton:(id)sender {
//Load URL Into WebView
NSString *urlAddress = @"http://www.pandora.com/account/sign-in";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_listenupwebkit setFrameLoadDelegate:delegate];
[[_listenupwebkit mainFrame] loadRequest:requestObj];
loginbutton.hidden = YES;
webkithome.enabled = YES;
}
和
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame*)frame
{
if(frame == [sender mainFrame]) {
NSLog(@"viewDidLoad");
}
}
我的.h文件
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame*)frame;
@end
最佳答案
提供实施
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame*)frame
在您的
frameLoadDelegate
中。[_listenupwebkit setFrameLoadDelegate:delegate];
[[_listenupwebkit mainFrame] loadRequest:requestObj];
在方法实现中,检查完成的框架是否为主框架:
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame*)frame
{
if(frame == [sender mainFrame]) {
关于objective-c - 完全加载UIWebView之后执行操作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11727229/