简体   繁体   English

`WKNavigationDelegate` `didFail` 和 `didFailProvisionalNavigation` 有什么区别

[英]What's the difference between `WKNavigationDelegate` `didFail` and `didFailProvisionalNavigation`

iOS WKWebView's WKNavigationDelegate has two methods to handle a failed navigation: iOS WKWebView 的WKNavigationDelegate有两种方法来处理失败的导航:

The docs only tell us that the one type occurs earlier in the navigation process than the other.文档只告诉我们,一种类型在导航过程中比另一种更早出现。 The error arguments are generic, so no help there.错误 arguments 是通用的,所以没有帮助。 Brave and Firefox iOS only handle didFailProvisionalNavigation as far as I can tell from reading their source. Brave 和 Firefox iOS 仅处理didFailProvisionalNavigation ,据我阅读其源代码可知。

My questions are:我的问题是:

  1. What's the difference exactly between the two types of errors?两种类型的错误之间到底有什么区别?
  2. Is there a list of errors that can occur for each?是否有每个错误可能发生的错误列表?
  3. When is it necessary to handle didFail seeing that browsers don't seem to handle that?什么时候有必要处理didFail看到浏览器似乎无法处理?

webView(_:didFailProvisionalNavigation:withError:) webView(_:didFailProvisionalNavigation:withError:)

This method handles errors that happen before the resource of the url can even be reached.此方法处理甚至可以到达 url 的资源之前发生的错误。 These errors are mostly related to connectivity, the formatting of the url, or if using urls which are not supported.这些错误主要与连接性、url 的格式或使用不受支持的 url 有关。

The error codes delivered here are found in https://developer.apple.com/documentation/c.network/c.networkerrors此处提供的错误代码位于https://developer.apple.com/documentation/c.network/c.networkerrors

Typical examples are典型的例子是

kCFURLErrorTimedOut = -1001 // timed out
kCFURLErrorUnsupportedURL = -1002 // unsupported URL
kCFURLErrorCannotFindHost = -1003 // host can not be found
kCFURLErrorFileDoesNotExist = -1100 // file does not exist on the server

webView(_:didFail:withError:)** webView(_:didFail:withError:)**

Here errors are reported that happen while loading the resource.这里报告加载资源时发生的错误。 These are usually errors caused by the content of the page, like invalid code in the page itself that the parser can't handle.这些通常是由页面内容引起的错误,例如页面本身中解析器无法处理的无效代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 swift中的:和=有什么区别 - What's the difference between : and = in swift CoreBluetooth和ExternalAccessory框架之间有什么区别? - What's the difference between the CoreBluetooth and ExternalAccessory frameworks? 可选:[String?]和[String]有什么区别? - Optionals: What's the difference between [String?] and [String]? 视图和超级视图有什么区别? - What's the difference between view and superview? downloadtaskwithrequest和downloadtaskwithurl之间的区别是什么 - What's the difference between downloadtaskwithrequest and downloadtaskwithurl NSCell和NSControl之间的关系/区别是什么? - What's is the relationship/difference between NSCell and NSControl? InstantiateInitialViewController和InstantiateViewControllerWithIdentifier之间有什么区别? - What's the difference between instantiateInitialViewController and instantiateViewControllerWithIdentifier:? `* .framework`,`* .dylib`和`* .a` libs有什么区别 - What's the difference between `*.framework`, `*.dylib` and `*.a` libs CoreData:performBackgroundTask和newBackgroundContext()之间有什么区别? - CoreData: What's the difference between performBackgroundTask and newBackgroundContext()? GCD中.userInitiated和.userInteractive有什么区别? - What's the difference between .userInitiated and .userInteractive in GCD?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM