3

このコードを使用して、地図上の場所を表示しています。

Class mapItemClass = [MKMapItem class];
if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)])
{
    // Create an MKMapItem to pass to the Maps app
    CLLocationCoordinate2D coordinate =
    CLLocationCoordinate2DMake(37.789658,-122.417479);
    MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate
                                                   addressDictionary:nil];
    MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
    [mapItem setName:@"My Place"];

    // Set the directions mode to "Walking"
    // Can use MKLaunchOptionsDirectionsModeDriving instead
    NSDictionary *launchOptions = @{MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving};
    // Get the "Current User Location" MKMapItem
    MKMapItem *currentLocationMapItem = [MKMapItem mapItemForCurrentLocation];
    // Pass the current location and destination map items to the Maps app
    // Set the direction mode in the launchOptions dictionary
    [MKMapItem openMapsWithItems:@[currentLocationMapItem, mapItem]
                   launchOptions:launchOptions];
}

このコードは、iPhone にある Apple マップ アプリに移動します。これは問題ありませんが、アプリに戻ることはありません。これを達成するための解決策を知っている人がいれば、私に提案してください。!!前もって感謝します。!!

4

2 に答える 2

3

残念ながら、あなたが望むことはできません。

ユーザーを別のアプリに送信すると、アプリが再びアクティブになる唯一の方法は、そのアプリがユーザーをアプリに明確に戻すか、ユーザーがアプリに戻ることです。

現在のところ、マップ アプリケーションはユーザーをアプリに返しません。あなたにできることは何もありません。

于 2013-04-06T04:30:32.787 に答える