Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 使用WebView WebView:didCommitLoadForFrame_Objective C_Xcode_Webkit_Webview - Fatal编程技术网

Objective c 使用WebView WebView:didCommitLoadForFrame

Objective c 使用WebView WebView:didCommitLoadForFrame,objective-c,xcode,webkit,webview,Objective C,Xcode,Webkit,Webview,我对Xcode相当陌生,所以请容忍我。我有一个小项目,并制作了一个类似这样的类: webController.m #import <Cocoa/Cocoa.h> #import "WebKit/WebView.h" #import "WebKit/WebFrame.h" @class WebView; @interface webController : NSObject { IBOutlet WebView *lyricWebView; } - (IBAction)l

我对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;
@end

我有一个链接到按钮的
loadWebPage
,但是我需要使用
stringByEvaluatingJavaScriptFromString
将一些脚本注入到网页,我需要在网页加载完成后运行这些脚本。我知道我需要使用
webView:didComitLoadForFrame
,但还没有找到如何或在何处实现它,以便在加载框架时运行它。我一整天都在四处张望。。。最后决定问。谢谢你的帮助

找到了!我只需要设置委托:D

对于任何可能需要它的人,您可以使用
[WebView setFrameLoadDelegate:self]进行设置。我的
-(void)上有这行代码,是从NIB中唤醒的。
- (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...");
}