重复使用的UIWebView在iPhone上短暂显示以前加载的内容 [英] Reused UIWebView showing previous loaded content for a brief second on iPhone

查看:81
本文介绍了重复使用的UIWebView在iPhone上短暂显示以前加载的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的某个应用中,我重复使用了一个webview。每次用户使用以下方法将重新加载缓存数据的特定视图输入到webview: -

In one of my apps I reuse a webview. Each time the user enters a certain view on reload cached data to the webview using the method :-


- ( void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)baseURL

我等待回拨电话


- (void)webViewDidFinishLoad :(UIWebView *)webView。

同时我隐藏了webview并显示'loading ' 标签。
只有当我收到webViewDidFinishLoad时,我才会显示webview。

In the mean time I hide the webview and show a 'loading' label. Only when I receive webViewDidFinishLoad do I show the webview.

很多时候我看到之前加载到webview的数据在短时间内发生了我加载的新数据开始了。

Many times what happens I see the previous data that was loaded to the webview for a brief second before the new data I loaded kicks in.

我在显示webview之前已经添加了0.2秒的延迟,但它没有帮助。

I already added a delay of 0.2 seconds before showing the webview but it didn't help.

而不是通过增加延迟时间来解决这个问题,有没有人知道如何解决这个问题,或者在没有发布的情况下从webview中清除旧数据并每次都分配它?

Instead of solving this by adding more time to the delay does anyone know how to solve this issue or maybe clear old data from a webview without release and allocating it every time?

推荐答案

感谢malaki1974,在我的情况下,我没有使用模态视图。
当我和WWDC 2010上的Apple工程师坐在一起并问他这个问题时,他的答案很简单:不要重复使用UIWebViews,这不是他们的使用方式。
从那时起,我确保在分配新的UIWebView之前调用这组行

Thanks malaki1974, in my case I wasn't using a modal view. When I sat with an Apple engineer on WWDC 2010 and asked him this question his answer was simply: "Don't reuse UIWebViews, that's not how they were ment to be used." Since then I make sure to calls this set of lines before allocating a new UIWebView

[self.myWebView removeFromSuperview];
self.myWebView.delegate = nil;
[self.myWebView stopLoading];
[self.myWebView release];

这解决了这个问题。

这篇关于重复使用的UIWebView在iPhone上短暂显示以前加载的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆