美文网首页iOS程序猿
加载webview报错Domain=WebKitErrorDom

加载webview报错Domain=WebKitErrorDom

作者: 呆呆滴木木菇凉 | 来源:发表于2016-10-26 20:21 被阅读0次

    错误1:Domain=WebKitErrorDomain Code=101
    1)检查是否有转义字符
    简单的很可能是你请求的url的NSString中含有未转义字符。未转义字符有很多,空格、竖线、百分号、中文字等算作未转义字符,转义后会成为 % 之类的字符。

    2)若没有转移字符
    如果确定url中均为未转义的字符,则可以用如下方式简便的方式进行url
    NSString *encodedString=[webUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:encodedString];

    错误2:
    Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."

    1) 在Info.plist中添加NSAppTransportSecurity类型Dictionary。
    2)在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES

    相关文章

      网友评论

        本文标题:加载webview报错Domain=WebKitErrorDom

        本文链接:https://www.haomeiwen.com/subject/sfhjuttx.html