Post

Replies

Boosts

Views

Activity

WKNavigationDelegate
I have a problem when using WKNavigationDelegate. It seems like only some of the delegate methods are working. I have implemented some of the methods below, just for testing purposes. I have only had one active at the time. Am I doing something wrong, or could it be something wrong with WKNavigationDelegate? extension MyViewController: WKNavigationDelegate { // Not called public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction) async -> WKNavigationActionPolicy { return .cancel } // Called // func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, preferences: WKWebpagePreferences) async -> (WKNavigationActionPolicy, WKWebpagePreferences) { // return (.cancel, preferences) // } // Not called // func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { // decisionHandler(.cancel) // } // Called // func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, preferences: WKWebpagePreferences, decisionHandler: @escaping (WKNavigationActionPolicy, WKWebpagePreferences) -> Void) { // decisionHandler(.cancel, preferences) // } // Not called // func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) { // decisionHandler(.cancel) // } // Not called // func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse) async -> WKNavigationResponsePolicy { // return .cancel // } }
1
0
520
Jun ’23