开发者

Using WebView webView:didCommitLoadForFrame

Im fairly new to Xcode, so please bear with me. I have a small porject, and made a class that looks like this:

webController.m

#import <Cocoa/Cocoa.h>
#import "WebKit/WebView.h"
#import "WebKit/WebFrame.h"

@class WebView;

@interface webController : NSObject {
    IBOutlet WebView *lyricWebView;

}
- (IBAction)loadWebPage:(id)sender;
@end

webController.h

- (IBAction)loadWebPage:(id)sender{
    NSLog(@"loading the page...");

    NSString *webpage = [NSString stringWithFormat:@"http://somepage.com"];

    [lyricWebVie开发者_如何转开发w setMainFrameURL:webpage]; 

}
- (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame
{
    NSLog(@"This is the problem...");
}

I have loadWebPage linked to a button, but I need to inject some scripts to the wepage using stringByEvaluatingJavaScriptFromString, which I need to run after the page has finished loading. I know I need to use webView:didComitLoadForFrame, but havent yet found out how or where to implement it so it will run when the frame is loaded. I've been looking arround all day... and decided finally to ask. Thanks for your help!


Figured it out! I just needed to set the delegate :D

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜