Instance Method

webView(_:decidePolicyFor:decisionHandler:)

Decides whether to allow or cancel a navigation.

Declaration

optional func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void)

Parameters

webView

The web view invoking the delegate method.

navigationAction

Descriptive information about the action triggering the navigation request.

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 WKNavigationActionPolicy.

Discussion

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

See Also

Permitting Navigation