如何使用sharedApplication在ios 6 apple map中显示位置

erc*_*can 4 maps ios ios6

在ios 5的应用程序中,我在地图中显示了一个按钮名称

例如,在商店详细信息视图中,有一个showinmap按钮,此按钮转到maps.google以显示用户的当前方向和商店方向,并且它还在这些方向之间绘制关于如何去那里的线

这是我的方法:

NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=Current+Location&daddr=%@,%@",lonlocation,latlocation];  

[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];                  
Run Code Online (Sandbox Code Playgroud)

但在ios 6中你知道没有谷歌地图应用程序.而不是苹果的新地图应用程序.

现在我的问题是如何在ios6版本中更改我的代码以使用苹果地图应用程序执行相同的工作?

Ali*_*are 7

只需更换maps.google.commaps.apple.com在您的网址,它的工作原理就像一个魅力:)

CGFloat sysVers = [UIDevice currentDevice].systemVersion.floatValue;
NSString* hostName = (sysVers < 6.0) ? @"maps.google.com" : @"maps.apple.com";

NSString* url = [NSString stringWithFormat: @"http://%@/maps?saddr=Current+Location&daddr=%@,%@",hostName,lonlocation,latlocation];  

[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];                  
Run Code Online (Sandbox Code Playgroud)

[编辑]正如@Vagari在他的回答中指出的那样,Apple似乎比我更好地整合了它,你maps.apple.com甚至可以在iOS5中指出你的所有URL :如果你发出它们,Apple会自动将你的URL重定向到maps.google.com来自iOS5上的设备!