【问题标题】:UIWebView not loading data sometime in iOS 9UIWebView 在 iOS 9 中的某个时候不加载数据
【发布时间】:2015-12-27 21:17:25
【问题描述】:

UIWebView 未在 iOS 9 中加载(移动网页)有时。我已经使用 NSAllowsArbitraryLoads 绕过 ATS。这些问题并非总是发生,并且在 iOS 7 和8. 调用了委托方法 webViewDidStartLoad,但根本没有调用 webViewDidFinishLoad 和 didFailLoadWithError。

【问题讨论】:

  • 对于 iOS 9,您可以使用 Safari 视图控制器。

标签: uiwebview ios9 wkwebview


【解决方案1】:

找到了解决方案。您需要做的就是在 iOS 9 中删除 UIWebView 并使用 WKWebView。我的网页有一些第三方调用 twitter、instagram 等 https。我也得到了 Auth在我的网页中挑战..! (即使我禁用了 ATS)。我通过使用 WKWebView 发现了这一点,它具有处理身份验证挑战的委托。

设置以下委托以获取身份验证挑战并进行处理。

- (void)webView:(WKWebView *)webView
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler

{
    SecTrustRef serverTrust = challenge.protectionSpace.serverTrust;
    CFDataRef exceptions = SecTrustCopyExceptions(serverTrust);
    SecTrustSetExceptions(serverTrust, exceptions);
    CFRelease(exceptions);

    completionHandler(NSURLSessionAuthChallengeUseCredential,
                      [NSURLCredential credentialForTrust:serverTrust]);

}

【讨论】:

    猜你喜欢
    • 2015-12-17
    • 2013-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-01
    • 1970-01-01
    • 2012-08-19
    相关资源
    最近更新 更多