当WebView完全加载页面时,有没有办法让我运行一些代码? 这是我用来在视图中打开网页的代码,如果这有帮助的话。
//Load URL Into WebView
NSString *urlAddress = @"http://example.com";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[[_listenupwebkit mainFrame] loadRequest:requestObj];
- (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");
}
}
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame*)frame;
@end
答案 0 :(得分:1)
提供
的实施- (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]) {