UIWebview没有给出shouldStartLoadWithRequest的日志

时间:2019-06-23 09:21:38

标签: swift uiwebview shouldstartload

下面是我为Webview设置的html文本。

<html>
<head>
<style type='text/css'>
body {background-color: transparent;border: 0px;margin: 0px;padding: 0px;font-family: 'AppleSDGothicNeo-Regular'; font-size: 17.25px;color:#5d5d5d;}
</style>
</head>
<body dir='LTR'>
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3478.137239196566!2d48.06220791499079!3d29.33697348214526!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3fcf9d974321ae81%3A0x911b0a9221b51465!2sBaboonej+cafe+kw!5e0!3m2!1sen!2skw!4v1555236627088!5m2!1sen!2skw" frameborder="0" style="border:0" allowfullscreen>
</iframe>
<style type='text/css'> iframe { width: 100%; height : 100%; } img {width: 100%% !important; height: auto;} a {text-decoration: none; color : #5d5d5d} table {width: 100%% !important;} }
</style>
</body>
</html>

作为回应,我得到如下的iframe。

enter image description here

当我单击View larger map或那里的任何链接时,我希望调用下面委托方法中的日志。但没有人被呼唤。有什么原因吗?

func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {

    print("shouldStartLoadWith")

    let surl : String = (request.url?.absoluteString)!

    print("surl=2==\(surl)")

    return true
}

func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {

    print("shouldStartLoadWithRequest")

    let surl : String = (request.url?.absoluteString)!

    print("surl=1==\(surl)")


    return true
}

我想知道是否在地图iframe上单击了任何链接,因为我需要基于链接进行一些操作。

0 个答案:

没有答案