How can I restore a WKWebView to the state it was before the app closed?

前端 未结 2 1497
我寻月下人不归
我寻月下人不归 2021-01-14 11:00

I run into a dead end. I just can\'t figure out a way for restoring a WKWebView after the user has closed the app. All the web pages he visited must be there when he re-open

相关标签:
2条回答
  • 2021-01-14 11:36

    you can store webpages in [NSDefaults standardUserDefaults] whenever the WKWebView has loaded.

    - (void)webView:(WKWebView *)webView didFinishNavigation: (WKNavigation *)navigation{
    
    }
    
    0 讨论(0)
  • 2021-01-14 11:42

    All the web pages he visited must be there when he re-opens it

    Impossible. The history of web pages visited - the backForwardList, and all its contents - is read-only. Nor is it saved and restored for you when you participate in view controller state saving and restoration.

    In my opinion, this is a major flaw in WKWebView.

    If you need this feature, revert to UIWebView, where it's all done for you like magic if you participate in view controller state saving and restoration.

    0 讨论(0)
提交回复
热议问题