我正在 Webview 中加载远程 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];
}