ios WKWebView Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified

最近在使用WKwebview(UIWebView 占用内存太大,而且还有内存泄漏问题)加载一个服务端的网页时候遇到这个问题,首先你要看一下你的Htttps 和Http 设置如下
这里写图片描述
发现没用,网上找了好多资料,大部分说先 [self.webView loadRequest:request]; 然后在addSubView 我发现也没用,后来又设置NSHTTPCookie 如下

NSMutableDictionary*cookieProperties =[NSMutableDictionary dictionary];
    [cookieProperties setObject:@"username" forKey:NSHTTPCookieName];
    [cookieProperties setObject:@"false" forKey:@"HttpOnly"];
    NSHTTPCookie *cookie =[NSHTTPCookie cookieWithProperties:[NSDictionary dictionaryWithObjectsAndKeys:@"false",@"HttpOnly", nil]];
     NSHTTPCookie *cookie =[NSHTTPCookie cookieWithProperties:cookieProperties];
        [[NSHTTPCookieStorage sharedHTTPCookieStorage]setCookie:cookie];
    NSHTTPCookie *cookieWID = [NSHTTPCookie cookieWithProperties:[NSDictionary dictionaryWithObjectsAndKeys: @"wid" ,NSHTTPCookieName,  @"",NSHTTPCookiePath, @"false",@"HttpOnly", nil]];
     [[NSHTTPCookieStorage sharedHTTPCookieStorage]setCookie:cookieWID];
    NSArray *cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage].cookies;
    //Cookies数组转换为requestHeaderFields
    NSDictionary *requestHeaderFields = [NSHTTPCookie requestHeaderFieldsWithCookies:cookies];

    //设置请求头
    request.allHTTPHeaderFields = requestHeaderFields;

发现设置NSHTTPCookie 也没有用,后来又检查了一下代码,发现我的URL 没有进行编码

[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

目前对这个问题的网上大多数解决办法

欢迎加入QQ技术交流群:476323497

你可能感兴趣的:(IOS,IOS开发)