菜鸟教程小白 发表于 2022-12-11 18:53:37

ios - 什么时候navigationAction.navigationType == .linkActivated?


                                            <p><p>在 WKWebView 中,每次点击 URL 时,<code>navigationType</code> 都是 <code>.other</code>。 <code>navigationType</code> 何时等于 <code>.linkActivated</code>?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>不太可能。也许您对原始值的解释有误?</p>

<pre><code>func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -&gt; Void) {
    print(navigationAction.navigationType.rawValue)
    // -1 &#34;other&#34; seen when assigning the url programatically
    // 0 &#34;linkActivated&#34; a link with an href attribute was tapped
    // 3 &#34;reload&#34; page was refreshed
}
</code></pre>

<p>见 <a href="https://developer.apple.com/documentation/webkit/wknavigationtype" rel="noreferrer noopener nofollow">the docs</a>您可以在其中单击列出的枚举并查看它们的原始值</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 什么时候navigationAction.navigationType == .linkActivated?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/46548202/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/46548202/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 什么时候navigationAction.navigationType == .linkActivated?