Open iOS6 Apple Maps app from a link in a UIWebView

╄→尐↘猪︶ㄣ 提交于 2019-12-05 09:18:19

Yes, there is a way to open a maps.apple.com link into the Maps app from a UIWebview. Don't have the UIWebview open the link directly, but pass it off to the OS to sort out. In webView: shouldStartLoadWithRequest: navigationType:, I look for the maps link and treat it specially:

if (([url.scheme isEqualToString:@"http"] || [url.scheme isEqualToString:@"https"]) && [url.host isEqualToString:@"maps.apple.com"]) { //it's an apple maps app request
    NSLog(@"Attempting Apple Maps app open");
    [[UIApplication sharedApplication]openURL:url];
    return NO;
}

And that opens the Apple Maps app in iOS6. In iOS5, it will open the google maps webpage in Safari. I'll look for iOS5 systems and treat the URL differently there, too.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!