私は iOS < 6 用にビルドされたアプリを持っていますが、それ以前はすべての機能が完全に動作していました。デバイスにインストールされている iOS を認識するスイッチを使用すると、アプリが正しいマップを開いて、ローカル位置から別の位置 (マップ上のいくつかのピン) への道順を取得します。問題は、iOS 6 より前では、アプリがネイティブ マップを開き、ルートをユーザーに表示することです。現在、デバイスが iOS 6 を使用している場合、アプリは Apple マップを開きますが、「この 2 つの位置の間で方向を取得できません」などのポップアップが表示されます。なんで?誰かがこの問題を解決するのを手伝ってくれますか?
ここでは、開示ボタンからマップに座標を渡す方法を示します。
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
[self.navigationController pushViewController:[[UIViewController alloc] init] animated:YES];
if (SYSTEM_VERSION_LESS_THAN(@"6.0")) {
NSString* addr = [NSString stringWithFormat:@"http://maps.google.com/maps?daddr=%1.6f,%1.6f&saddr=Posizione attuale", view.annotation.coordinate.latitude,view.annotation.coordinate.longitude];
NSURL* url = [[NSURL alloc] initWithString:[addr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];
}
else {
NSString* addr = [NSString stringWithFormat:@"http://maps.apple.com/maps?daddr=%1.6f,%1.6f&saddr=Posizione attuale", view.annotation.coordinate.latitude,view.annotation.coordinate.longitude];
NSURL* url = [[NSURL alloc] initWithString:[addr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];
}