问题描述:iOS9和iOS10用WKWebView加载URL都没有问题,iOS11却是一片空白
可能是用了NSMutableURLRequest
,iOS11貌似不支持NSMutableURLRequest
,无论是用UIWebView
还是WKWebView
,都不支持NSMutableURLRequest
解决方法参考
if #available(iOS 11, *) {
let request = NSURLRequest.init(url: URL.init(string: urlStr)!)
self.wkWebView.load(request as URLRequest)
}else{
let request = NSMutableURLRequest.init(url: URL.init(string: urlStr)!, cachePolicy: NSURLRequest.CachePolicy.reloadIgnoringLocalAndRemoteCacheData, timeoutInterval: 60)
request.httpMethod = "GET"
request.httpBody = ("token=" + tokenValue()).data(using: String.Encoding.utf8)
self.wkWebView.load(request as URLRequest)
}