我正在使用此代码在 map 上显示一些位置。
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 中存在的苹果 map 应用程序,这没问题,但它不会将我带回我的应用程序。 如果有人知道实现此目的的任何解决方案,请建议我。 !!提前致谢。!!
最佳答案
很遗憾,您想要的无法完成。
一旦您将用户转到另一个应用,您的应用再次激活的唯一方法是该应用专门将用户返回到您的应用,或者让用户导航回您的应用。
截至目前, map 应用程序不会将用户返回到您的应用程序。您无能为力。
关于iphone - 从 iOS 6 中的应用程序映射应用程序后如何返回我的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15847011/