iPhone SDK - WebView活动指示器

发布于 2024-08-19 06:24:18 字数 673 浏览 9 评论 0原文

我对 iPhone SDK 中的 UIWebView 有一个大问题。 我有一个 TabBarApplication,每个选项卡上都有一个 WebView(第一个选项卡除外)。

因为加载视图需要安静一段时间,所以我想显示活动指示器。

这是我用来执行此操作的代码:

-(void)webViewDidStartLoad:(UIWebView *) portal {

[UIApplication sharedApplication].networkActivityIndi​​catorVisible = YES; 它

-(void)webViewDidFinishLoad:(UIWebView *) portal{
 [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; 
}

不能这样工作...我的第一个选项卡中的 WebView 称为“portal”,这就是我在上面输入它的原因,但如果我使用 WebView 也存在同样的问题。

有什么想法吗?这不可能是真的,这太困难了。 我正在安静地寻找线索一段时间,但没有找到任何可以帮助我构建这样一个(认为很容易)活动指示器的东西。

非常感谢您的努力!

来自德国的问候 托比亚斯

I have a big problem with the UIWebView in iPhone SDK.
I have a TabBarApplication with one WebView on each Tab (except the first).

Because it takes quiet a while to load the views I'd like to show an activity indicator.

Here is the code I'm using in order to do that:

-(void)webViewDidStartLoad:(UIWebView *) portal {

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}

-(void)webViewDidFinishLoad:(UIWebView *) portal{
 [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; 
}

It doesn't work this way... My WebView in the first tab is called "portal", that's why I entered it above, but the same problem exists if I use WebView.

Any ideas? Can't be true that this is soooo difficult.
I'm searching for a clue quiete a while now and found nothing which helped me to build such a (think it's easy) activityindicator.

Thanks a lot for your effort!

Greets from Germany
Tobias

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨洒年华 2024-08-26 06:24:18

我通常使用 UIActivityIndi​​catorView。

如果您在网络视图之上有一个导航控制器,它可以完美地工作:

-(void)webViewDidStartLoad:(UIWebView *) portal {
UIActivityIndicatorView *actInd = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
UIBarButtonItem *actItem = [[UIBarButtonItem alloc] initWithCustomView:actInd];

self.navigationItem.rightBarButtonItem = actItem;

[actInd startAnimating];
[actInd release];
[actItem release];
}

要摆脱指示器:

-(void)webViewDidFinishLoad:(UIWebView *) portal{
 self.navigationItem.rightBarButtonItem = nil;
}

如果您没有使用导航控制器,那么我只需使用较大的样式 UIActivityIndi​​catorViewStyleWhiteLarge 或将视图放在屏幕上的深色半透明视图,然后在加载完成时将其删除。

I typically use a UIActivityIndicatorView.

If you have a Navigation Controller on top of the web view it works perfectly:

-(void)webViewDidStartLoad:(UIWebView *) portal {
UIActivityIndicatorView *actInd = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
UIBarButtonItem *actItem = [[UIBarButtonItem alloc] initWithCustomView:actInd];

self.navigationItem.rightBarButtonItem = actItem;

[actInd startAnimating];
[actInd release];
[actItem release];
}

To get rid of the indicator:

-(void)webViewDidFinishLoad:(UIWebView *) portal{
 self.navigationItem.rightBarButtonItem = nil;
}

If you aren't using a Navigation Controller then I would simply use either the larger style, UIActivityIndicatorViewStyleWhiteLarge OR place the view on top of a dark semi-transparent view on the screen and then remove them on load finish.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文