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?
I’ve tried:
while ([webview canGoback]) {
[webview goBack];
}
but that will freeze the device (simulator too).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
UIWebViewit 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
myUIWebViewInstanceis a perfectly normal instance ofUIWebView:There is also the rather tempting
_clearBackForwardCachemethod in the framework, however it didn’t seem to do much when tickled. Just flipping the boolian worked a treat for me.