我对Xcode相当陌生,所以请容忍我。我有一个小房间,并做了一个类似于这样的类:
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;
@endwebController.h
- (IBAction)loadWebPage:(id)sender{
NSLog(@"loading the page...");
NSString *webpage = [NSString stringWithFormat:@"http://somepage.com"];
[lyricWebView setMainFrameURL:webpage];
}
- (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame
{
NSLog(@"This is the problem...");
}我有loadWebPage链接到一个按钮,但是我需要使用stringByEvaluatingJavaScriptFromString向网页注入一些脚本,在页面加载完成后我需要运行这个脚本。我知道我需要使用webView:didComitLoadForFrame,但是还没有找到如何或在哪里实现它,以便在加载框架时运行它。我找了一整天.最后决定问。谢谢你的帮忙!
发布于 2011-04-20 03:18:11
弄明白了!我只需要设置代表:D
https://stackoverflow.com/questions/5446634
复制相似问题