1.描述:因公司域名更換https,因而造成在wkwebView中某些網址打不開,查看錯誤是因為服務器證書無效,實際就是不受信任;??
2.解決辦法:在plist文件中設置
Allow?Arbitrary?Loads?in?Web?Content?置為?YES,
假如有設置NSAllowsArbitraryLoads??為?YES,可不用設置上面,理由下圖:
3、并實現wkwebView下面的代理方法,就可解決? :?
-?(void)webView:(WKWebView?*)webView?didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge?*)challenge?completionHandler:(void?(^)(NSURLSessionAuthChallengeDisposition?disposition,?NSURLCredential?*?_Nullable?credential))completionHandler{? if?([challenge.protectionSpace.authenticationMethod?isEqualToString:NSURLAuthenticationMethodServerTrust])?{? NSURLCredential?*card?=?[[NSURLCredential?alloc]initWithTrust:challenge.protectionSpace.serverTrust];??completionHandler(NSURLSessionAuthChallengeUseCredential,card);? ?}
}?
command+r試試吧!