【问题标题】:How to open Apple Map App on iOS App inside HTML如何在 HTML 内的 iOS App 上打开 Apple Map App
【发布时间】:2017-12-05 08:44:35
【问题描述】:

现在,我通过 WKWebView 嵌入了 HTML。如果用户点击a元素,我想打开苹果地图APP。似乎什么都没有发生,只是背景颜色发生了变化。 我的代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        a {
            display: block;
            font-size: 20px;
            width: 200px;
            height: 100px;
            margin: 100px auto;
            text-align: center;
        }
    </style>
</head>
<body>

<h1>open the  apple map</h1>

<a href="maps:ll=38.897096,-77.036545" class="context-block-button map-button" id="map-button-1"><i class="ss-map icon-left"></i><span>Open in map (maps:)</span></a>

</body>
<script src="../js/jquery.min.js"></script>
<script>
    $('body').on('click','a',function () {
            $('body').css('background-color','blue');
      window.location.href = " http://maps.apple.com/?q=Mexican+Restaurant&sll=50.894967,4.341626&z=10&t=s";
    })
</script>
</html>

在 safari 中,我复制“http://maps.apple.com/?q=Mexican+Restaurant&sll=50.894967,4.341626&z=10&t=s”。然后 safari 将在 Mac 上打开 Apple App。

我必须使用Swift4 API 来打开 Apple 地图应用程序吗? 还有一件事,如果解决方案必须更改 info.plist 或更改 App 目标设置,谢谢你为我写这篇文章。

【问题讨论】:

    标签: javascript ios swift html


    【解决方案1】:

    是的,你需要使用Swift API,需要实现WKNavigationDelegate,添加decisionPolicyForNavigationAction方法。

    从另一个线程检查这个answer

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-08
      相关资源
      最近更新 更多