【发布时间】:2014-11-06 00:34:25
【问题描述】:
我在我的应用程序中创建了一些 WkWebViews,但是当为一个 webview 设置 cookie 时,它们不会在其他 webview 中生效(即其他 webviews 不会将相同的 cookie 传递回服务器)。如何让它们都使用相同的 cookie 存储?
【问题讨论】:
标签: ios objective-c ios8 wkwebview
我在我的应用程序中创建了一些 WkWebViews,但是当为一个 webview 设置 cookie 时,它们不会在其他 webview 中生效(即其他 webviews 不会将相同的 cookie 传递回服务器)。如何让它们都使用相同的 cookie 存储?
【问题讨论】:
标签: ios objective-c ios8 wkwebview
通过对所有 webview 使用相同的 WKProcessPool 来实现此功能。
首先在某处创建一个进程池一次:
processPool = [[WKProcessPool alloc] init];
然后在创建 WKWebviews 时使用它。池必须在 init 方法中设置,而不是之后。
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
config.processPool = processPool;
webview = [[WKWebView alloc] initWithFrame:frame configuration:config];
【讨论】: