How to clear back forward list in UIWebview on iPhone?(如何在 iPhone 上的 UIWebview 中清除后退列表?)
问题描述
我想访问/清除后退列表,就好像 UIWebView 又是新的一样.是否有任何公共 API 或解决方法可以做到这一点?
I want to access/clear the back forward list as if the UIWebView is new again. Is there any public API or workaround to do this?
我试过了:
while ([webview canGoback]) {
[webview goBack];
}
但这会冻结设备(模拟器也是).
but that will freeze the device (simulator too).
推荐答案
免责声明
与任何类似的事情一样,请记住,结果可能无法通过应用商店的批准,并且可能根本不适用于 SDK 的未来修订版.
SDK 中没有官方 方法可以做到这一点.但是,如果您真的想清除 UIWebView 的后退/前进历史记录,可以通过深入研究私有框架来完成.
There is no official method for doing this in the SDK. However if you really want to clear the back/forward history of a UIWebView it can be done with a little delve into the private frameworks.
一个快速而肮脏的方法(完成一堆丑陋的编译器警告)如下:
A quick and dirty way to do it (complete with a bunch of ugly compiler warnings) is as follows:
鉴于 myUIWebViewInstance 是一个完全正常的 UIWebView 实例:
Given that myUIWebViewInstance is a perfectly normal instance of UIWebView:
id internalWebView=[[myUIWebViewInstance _documentView] webView];
[internalWebView setMaintainsBackForwardList:NO];
[internalWebView setMaintainsBackForwardList:YES];
框架中还有一个比较诱人的_clearBackForwardCache方法,不过在tick的时候好像没什么作用.只是翻转布尔值对我来说是一种享受.
There is also the rather tempting _clearBackForwardCache method in the framework, however it didn't seem to do much when tickled. Just flipping the boolian worked a treat for me.
这篇关于如何在 iPhone 上的 UIWebview 中清除后退列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 iPhone 上的 UIWebview 中清除后退列表?
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
