【问题标题】:Loading Maps App from iOS SDK 6.1 with Target iOS 5.0使用 Target iOS 5.0 从 iOS SDK 6.1 加载 Maps App
【发布时间】:2013-01-31 18:12:38
【问题描述】:

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

一个功能是将用户带到地图应用程序。 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 网站,而不是本地地图应用程序。

这可以解决吗?

编辑

到目前为止,我有这个:

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]];
}

【问题讨论】:

    标签: iphone ios ipad ios6 mapkit


    【解决方案1】:

    Apple 已更新其对地图的 URL 处理,您需要指向 maps.apple.com,这将适当地重定向到 Google。 See the documentation for more/how.

    【讨论】:

    • 刚刚在我的应用程序中将maps.google.com 替换为maps.apple.com 并进行了测试,但同样的问题仍然存在。
    • 这可能是一个错误,(developer.apple.com/library/ios/#documentation/UserExperience/…) 的底部声明对于 iOS 5,您需要使用 URL 方案。这链接到我做的同一页面。
    • +1 你为我指明了正确的方向。更彻底地阅读规范,URL 必须以http://maps.apple.com/?q 开头。 (?q 很关键。)现在它可以工作了。 :-) 谢谢!
    【解决方案2】:

    链接的答案看起来不错。您需要做的就是通过something like this 检查用户正在运行的iOS 版本,并针对iOS 6 案例和iOS 小于6 案例执行相应的代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多