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).
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).
If you're trying to "reuse" an existing UIWebView, and disable the ability to go back to whatever previous page it was in before, you can:
When loading the new request (the one that user shouldn't go back from), save the URL of the new request, say like:
self.curURL = [NSURL urlWithString:@"http://www.bla.com"];
[webview loadRequest:[NSURLRequest requestWithURL:curURL]];
I'm guessing you have your own back button, so on your webViewDidFinishLoad delegate method, add:
backbttn.enabled = webView.canGoBack && ![[webView.request URL] isEqual: curURL];
This way, the user won't even know that the UIWebView can go back to the page before.
I think if you release the uiwebview object and recreate then it would clear the history. I actually have a reverse problem. My uiwebview object automatically gets released during low memory event if it's inside a nonvisible view. I then have to recreate it in viewDidLoad but it does not retain the history from that point onwards.