首先,我发布了这个,因为所有其他教程都不起作用。 好的,这是我的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)地图应用程序。
答案 0 :(得分:0)
它将在设备中打开苹果地图应用
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]];