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-opens it.
Any suggestions?
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-opens it.
Any suggestions?
当他重新打开它时,他访问的所有网页都必须在那里
不可能的。访问过的网页的历史记录 -backForwardList
及其所有内容 - 是只读的。当您参与视图控制器状态保存和恢复时,它也不会为您保存和恢复。
在我看来,这是 WKWebView 的一大缺陷。
如果您需要此功能,请恢复到 UIWebView,如果您参与视图控制器状态保存和恢复,这一切都会像魔术一样为您完成。
您可以在加载时将网页存储在 [NSDefaults standardUserDefaults]WKWebView
中。
- (void)webView:(WKWebView *)webView didFinishNavigation: (WKNavigation *)navigation{
}