6

I'd like to clear the back forward list of a WKWebView when the user taps a button.

I can't find anything useful in Apple documentation but I found the same question related to UIWebView : How to clear back forward list in UIWebview on iPhone?

Unfortunately, I don't really like the given answers as they are either risky considering the app review process or they just don't work. So I was wondering if there was something new with WKWebView that could help me to achieve that. I'm kind of hopeless as it's been a while now that I'm looking for a solution but we never know...

Community
  • 1
  • 1
Randy
  • 4,335
  • 3
  • 30
  • 64

1 Answers1

4

Dirty workaround

For now, I reinitialise my WKWebView ( myWebView = WKWebView() ) and I redefine its constraints ( as they are, of course, broken when I reinitialise the web view ).

What I don't really like here is that I reinitialise the whole web view whereas I just want to clear its back forward list.

Randy
  • 4,335
  • 3
  • 30
  • 64
  • I had to do the same in the end with my ```WKWebView``` (in my macOS app). Just don't forget to set the various properties again (i.e.: back/forward gestures, etc...). – Supertecnoboff Jul 12 '17 at 09:20
  • I added wkwebview to my app form the uibuilder, and don't set any properties from code. How do I reinitialize and redefine it's constraints in this case? I am using objective C, main aim is to clear history, I will only load html and image files in the container Documents folder – user13267 Aug 12 '19 at 07:10