【问题标题】:Native Apple Maps UIWebView referal原生苹果地图 UIWebView 推荐
【发布时间】:2013-12-18 04:59:36
【问题描述】:

首先,我发布了这个,因为所有其他教程都不起作用。 好的,这是我的 HTML 代码

<a href="http://maps.apple.com/?daddr=1/76+Ferry+Rd,+Southport&saddr=Current+Location">Directions</a>

我也有这个

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    if ([[request.URL description] hasPrefix:@"http://maps"])
        // open URL in Safari and return NO to prevent UIWebView from load it
        [[UIApplication sharedApplication] openURL:[request URL]];
        return NO;
    };

但每次我点击上面的链接时,它都会将我重定向到 UIWebView 上的谷歌地图,但我希望它能够将我重定向到 (Apple) Maps 应用程序。

【问题讨论】:

  • 检查这里可能对你有帮助stackoverflow.com/questions/14521689/…
  • @Bhumeshwerkatre 我已经看过了,但它对我没有用,它只是直接回到谷歌,而且我需要多个链接,我需要大量(比如超过 9,000 个)
  • 我也有兴趣解决这个问题。最奇怪的是,该链接在移动 safari(打开 Apple 地图)中正常工作,但在应用程序内的 web 视图中却不能正常工作(链接到 Google 地图的网络版本)。

标签: ios iphone objective-c uiwebview maps


【解决方案1】:

它将在设备中打开苹果地图应用程序

    NSString *ll = [NSString stringWithFormat:@"%f,%f",latitude,longitude];
    ll = [ll stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSString *url = [NSString stringWithFormat:@"http://maps.apple.com/?q=%@", ll];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];

【讨论】:

  • 我可以在 uiwebview 中打开这个网址吗?
猜你喜欢
  • 1970-01-01
  • 2020-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多