坑一:
WKWebView會忽視默認的網(wǎng)絡存儲, NSURLCache, NSHTTPCookieStorage, NSCredentialStorage蕾殴。 目前是這樣的锯玛,WKWebView有自己的進程,同樣也有自己的存儲空間用來存儲cookie和cache澳淑, 其他的網(wǎng)絡類如NSURLConnection是無法訪問到的秋冰。 同時WKWebView發(fā)起的資源請求也是不經過NSURLProtocol的仲义,導致無法自定義請求。
wkwebview之間的同步問題,不同webview的sessionid不同,登陸態(tài)不同
解決方法:使用同一個WKProcesspool
self.sharedProcessPool = [[WKProcessPool alloc]init];
webViewConfiguration = [[WKWebViewConfiguration alloc] init];
WKUserContentController *contentController = [[WKUserContentController alloc] init];
webViewConfiguration.userContentController = contentController;
webViewConfiguration.processPool = self.sharedProcessPool;
官方文檔提示(海檳提問過)
The process pool associated with a web view is specified by its web view configuration. Each web view is given its own Web Content process until an implementation-defined process limit is reached; after that, web views with the same process pool end up sharing Web Content processes.