Disclaimer
As with anything like this, bear in mind that the results may not make it through app store approval and may not work at-all with future revisions of the SDK.
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:
Given that myUIWebViewInstance
is a perfectly normal instance of UIWebView
:
id internalWebView=[[myUIWebViewInstance _documentView] webView];
[internalWebView setMaintainsBackForwardList:NO];
[internalWebView setMaintainsBackForwardList:YES];
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…