Instance Method

webView(_:decidePolicyFor:decisionHandler:)

Decides whether to allow or cancel a navigation after its response is known.

Declaration

optional func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void)

Parameters

webView

The web view invoking the delegate method.

navigationResponse

Descriptive information about the navigation response.

decisionHandler

A block to be called when your app has decided whether to allow or cancel the navigation. The block takes a single parameter, which must be one of the constants of the enumerated type WKNavigationResponsePolicy.

Discussion

Your delegate can either call the block immediately or save the block and call it asynchronously at a later time.

See Also