IOS webview加载内容出现 Error Domain=NSURLErrorDomain Code=-999 "(null)"

Printing description of error: Error Domain=NSURLErrorDomain Code=-999 "(null)" 

出现错误的原因是因为webview在之前的请求还没有加载完成,下一个请求开始发起了,因此webview会取消掉之前的请求,便会回调到didFailLoadWithError。

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    // 被取消  这种错误我们可以采用暂不处理的方式
    if([error code] == NSURLErrorCancelled)  {
        return;
    }
}

/*!
    @enum NSURL-related Error Codes
    @abstract Constants used by NSError to indicate errors in the NSURL domain
*/
NS_ENUM(NSInteger)
{
    NSURLErrorUnknown =             -1,
    NSURLErrorCancelled =             -999,
    NSURLErrorBadURL =                 -1000,
    NSURLErrorTimedOut =             -1001,
    NSURLErrorUnsupportedURL =             -1002,
    NSURLErrorCannotFindHost =             -1003,
    NSURLErrorCannotConnectToHost =         -1004,
    NSURLErrorNetworkConnectionLost =         -1005,
    NSURLErrorDNSLookupFailed =         -1006,
    NSURLErrorHTTPTooManyRedirects =         -1007,
    NSURLErrorResourceUnavailable =         -1008,
    NSURLErrorNotConnectedToInternet =         -1009,
    NSURLErrorRedirectToNonExistentLocation =     -1010,
    NSURLErrorBadServerResponse =         -1011,
    NSURLErrorUserCancelledAuthentication =     -1012,
    NSURLErrorUserAuthenticationRequired =     -1013,
    NSURLErrorZeroByteResource =         -1014,
    NSURLErrorCannotDecodeRawData =             -1015,
    NSURLErrorCannotDecodeContentData =         -1016,
    NSURLErrorCannotParseResponse =             -1017,
    NSURLErrorAppTransportSecurityRequiresSecureConnection NS_ENUM_AVAILABLE(10_11, 9_0) = -1022,
    NSURLErrorFileDoesNotExist =         -1100,
    NSURLErrorFileIsDirectory =         -1101,
    NSURLErrorNoPermissionsToReadFile =     -1102,
    NSURLErrorDataLengthExceedsMaximum NS_ENUM_AVAILABLE(10_5, 2_0) =    -1103,
    
    // SSL errors
    NSURLErrorSecureConnectionFailed =         -1200,
    NSURLErrorServerCertificateHasBadDate =     -1201,
    NSURLErrorServerCertificateUntrusted =     -1202,
    NSURLErrorServerCertificateHasUnknownRoot = -1203,
    NSURLErrorServerCertificateNotYetValid =     -1204,
    NSURLErrorClientCertificateRejected =     -1205,
    NSURLErrorClientCertificateRequired =    -1206,
    NSURLErrorCannotLoadFromNetwork =         -2000,
    
    // Download and file I/O errors
    NSURLErrorCannotCreateFile =         -3000,
    NSURLErrorCannotOpenFile =             -3001,
    NSURLErrorCannotCloseFile =         -3002,
    NSURLErrorCannotWriteToFile =         -3003,
    NSURLErrorCannotRemoveFile =         -3004,
    NSURLErrorCannotMoveFile =             -3005,
    NSURLErrorDownloadDecodingFailedMidStream = -3006,
    NSURLErrorDownloadDecodingFailedToComplete =-3007,

    NSURLErrorInternationalRoamingOff NS_ENUM_AVAILABLE(10_7, 3_0) =         -1018,
    NSURLErrorCallIsActive NS_ENUM_AVAILABLE(10_7, 3_0) =                    -1019,
    NSURLErrorDataNotAllowed NS_ENUM_AVAILABLE(10_7, 3_0) =                  -1020,
    NSURLErrorRequestBodyStreamExhausted NS_ENUM_AVAILABLE(10_7, 3_0) =      -1021,
    
    NSURLErrorBackgroundSessionRequiresSharedContainer NS_ENUM_AVAILABLE(10_10, 8_0) = -995,
    NSURLErrorBackgroundSessionInUseByAnotherProcess NS_ENUM_AVAILABLE(10_10, 8_0) = -996,
    NSURLErrorBackgroundSessionWasDisconnected NS_ENUM_AVAILABLE(10_10, 8_0)= -997,
};

--------------------- 
作者:feiyue0823 
来源:CSDN 
原文:https://blog.csdn.net/feiyue0823/article/details/58604055 
版权声明:本文为博主原创文章,转载请附上博文链接!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值