gpt4 book ai didi

cocoa - Xcode 中的 Webview 加载微调器

转载 作者:行者123 更新时间:2023-12-03 16:39:39 27 4
gpt4 key购买 nike

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

最佳答案

Be the frame load delegate ,和stop the progress indicator's animation当主框架完成加载时。

仅当您收到 did-finish-load 消息的帧是 Web View 的主帧时才停止动画。对于 Web View 中的每个框架(包括嵌套框架和 iframe),您都会收到其中一条消息。您不想过早停止动画。

关于cocoa - Xcode 中的 Webview 加载微调器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2106918/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com