iphone - 使用 Target iOS 5.0 从 iOS SDK 6.1 加载 map 应用程序

标签 iphone ios ipad ios6 mapkit

我想在我使用 iOS 6.1 SDK 编译的应用程序中支持 iOS5。

一个功能是将用户带到 map 应用程序。 Here is a link解释如何使用适用于 iOS 5 的 iOS SDK 5 以及适用于 iOS 6 的 iOS SDK 6。

但是,如果我使用 iOS 6.1 SDK 并使用 iOS 5 设备,magic URL link根据需要,将我带到 Mobile Safari 中的 maps.google.com 网站,而不是本地 map 应用程序。

这可以修复吗?

编辑

到目前为止,我有这个:

BOOL appleMapsSupported = FALSE;
NSString *reqSysVer = @"6.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
    appleMapsSupported = TRUE;
if (appleMapsSupported){
    NSLog(@"device version %@", [[UIDevice currentDevice] systemVersion]);
    MKPlacemark* placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate addressDictionary:@{(NSString*)kABPersonAddressStreetKey:@"Your Place"}];
    MKMapItem* mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
    [mapItem openInMapsWithLaunchOptions:@{MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeWalking}];
}else{
    NSString* url = [NSString stringWithFormat:@"http://maps.google.com/?t=m&q=Your+Place%%40%g,%g", coordinate.latitude, coordinate.longitude];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

最佳答案

Apple 已经更新了他们对 map 的 URL 处理,您需要指向 maps.apple.com,它会适本地重定向到 Google。 See the documentation for more/how .

关于iphone - 使用 Target iOS 5.0 从 iOS SDK 6.1 加载 map 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14900304/

相关文章:

iphone - 如何正确使用__bridge for ARC

iphone - 使用 SDK 4.0 模拟 iPhone 3.0

iphone - 如何在XCode(iOS SDK)中添加按钮到注释 View

ios - 调整图像大小 Objective-C

ios - cocos2d 中 Sprite 的触摸 Action

iphone - 如何更改导航栏上 UIBarButtonItem 的字体颜色/文本颜色

ios - 如何以编程方式截取可扩展uitableview的屏幕截图

iphone - 在iOS应用程序中,即使没有添加主自定义UIView,我仍然可以添加其他 View 对象作为 subview ?

ios - 使用Core电话的iPhone手机号码

ios - 核心图像与核心图形