关闭模式视图时清除 UIWebView 内容(iPhone OS 3.0) [英] Clear UIWebView content upon dismissal of modal view (iPhone OS 3.0)

查看:32
本文介绍了关闭模式视图时清除 UIWebView 内容(iPhone OS 3.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个显示在模式视图中的 UIWebView.它基本上是一个详细视图,在用户单击链接时提供页面视图.当视图被关闭然后再次打开时(当用户单击另一个链接时),之前加载的内容仍然可见,并且新内容加载到最后一个内容的顶部".这是有道理的,因为 UIWebView 的实例在会话之间持续存在,并且仅在需要内存时才释放.

I currently have a UIWebView that is displayed within a modal view. It is basically a detail view that provides a view of a page when the user clicks a link. When the view is dismissed and then brought up again (when the user clicks another link), the previously-loaded content is still visible and the new content loads "on top" of the last content. This makes sense because the instance of the UIWebView persists between sessions and is only released when the memory is needed.

但是,我想在模式视图被关闭时完全清除 UIWebView,以便 1)清除内容和 2)释放内存.到目前为止,我的研究和尝试还没有找到答案.这些链接对我不起作用:

However, I would like to completely clear the UIWebView when the modal view is dismissed so that 1) content is cleared and 2) memory is freed. Thus far my research and attempts have not found an answer. These links haven't worked for me:

  1. 是否可以释放 UIWebView 的内存?
  2. 重用 UIWebView 显示以前加载iPhone 上短暂的内容

我试过 [[NSURLCache sharedURLCache] removeAllCachedResponses]; 并将 webView 设置为 nil 并在 modal-view-dismiss 时手动释放 webView 无济于事.干瘪群众有什么想法吗?

I've tried [[NSURLCache sharedURLCache] removeAllCachedResponses]; and setting the webView to nil and manually releasing the webView upon modal-view-dismiss to no avail. Any thoughts from the wizened masses?

推荐答案

释放 Web 视图可能是最好的方法.如果视图在视图层次结构中(具有父视图),则必须调用 removeFromSuperview 以获取父视图以释放视图.

Releasing the web view is probably the best approach. If a view is in a view hierarchy (has a superview) you must call removeFromSuperview to get the superview to release the view.

您还可以为空文档加载 html 字符串:

You could also load an html string for an empty document:

[webView loadHTMLString:@"<html><head></head><body></body></html>" baseURL:nil];

这篇关于关闭模式视图时清除 UIWebView 内容(iPhone OS 3.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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