Cocoa Webview在Xcode中加载微调器

Cocoa Webview在Xcode中加载微调器,cocoa,webkit,nsprogressindicator,Cocoa,Webkit,Nsprogressindicator,我正在Web视图中加载一个远程URL,我想在加载内容时显示一个微调器。我有以下代码,但是当内容加载完成时,微调器不会消失。如何使微调器在加载内容后消失 NSURL *noteURL = [NSURL URLWithString:@"http://google.com/"]; NSString *defaultNote = @"Hello there"; NSRect frame = [[noteView superview] frame]; noteSpinner = [[[NSProgres

我正在Web视图中加载一个远程URL,我想在加载内容时显示一个微调器。我有以下代码,但是当内容加载完成时,微调器不会消失。如何使微调器在加载内容后消失

NSURL *noteURL = [NSURL URLWithString:@"http://google.com/"];
NSString *defaultNote = @"Hello there";

NSRect frame = [[noteView superview] frame];
noteSpinner = [[[NSProgressIndicator alloc] initWithFrame:NSMakeRect(NSMidX(frame)-16, NSMidY(frame)-16, 32, 32)] autorelease];
[noteSpinner setStyle:NSProgressIndicatorSpinningStyle];
[noteSpinner startAnimation:self];
//webViewFinishedLoading = NO;
[[noteView superview] addSubview:noteSpinner];

if (noteURL)
{
    if ([noteURL isFileURL])
    {
        [[noteView mainFrame] loadHTMLString:@"Release notes with file:// URLs are not supported for security reasons—Javascript would be able to read files on your file system." baseURL:nil];
    }
    else
    {
        [[noteView mainFrame] loadRequest:[NSURLRequest requestWithURL:noteURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]];
    }
}
else
{
    [[noteView mainFrame] loadHTMLString:defaultNote baseURL:nil];
}
,并且当主机架完成加载时


仅当接收到“已完成加载”消息的帧是web视图的主帧时,才停止动画。对于web视图中的每个帧,包括嵌套帧和iFrame,您都会收到其中一条消息。您不想过早地停止动画。

我如何知道主帧何时完成加载?没关系,明白了。对于记录,需要在同一类中定义以下函数:-(void)webView:(webView*)sender didFinishLoadForFrame:frame{if([frame parentFrame]==nil){[noteSpinner setHidden:YES];[sender display];}测试主框架的另一种方法是向web视图询问其主框架,并检查完成加载的框架是否是相同的框架。