-->

如何从地图应用程序在IOS 6号出口即控制返回给应用程序请求指导?(How to exit from

2019-10-17 18:24发布

我使用MKMapItem从用户点击“行车路线”按钮后,我的应用程序中启动地图应用程序。 地图应用程序中,从当前位置精准的显示方向来了一个地址。 但我怎么回去我的应用程序,如果我不再希望看到的方向? 下面是我的连接代码IBAction

码:


- (IBAction)pressDirectionsButton:(id)sender {

Class mapItemClass = [MKMapItem class];
if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)])
{
    CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    NSString *addressString = [NSString stringWithFormat:@"%@,%@,%@,%@,%@",
                               self.currentlySelectedTemple.houseNumber,
                               self.currentlySelectedTemple.street,
                               self.currentlySelectedTemple.city,
                               self.currentlySelectedTemple.state,
                               self.currentlySelectedTemple.country];
    [geocoder geocodeAddressString:addressString completionHandler:^(NSArray *placemarks, NSError *error) {

        //Convert CLPlacemark to an MKPlacemark
        CLPlacemark *geocodedPlacemark = [placemarks objectAtIndex:0];
        MKPlacemark *placemark = [[MKPlacemark alloc]
                                  initWithCoordinate:geocodedPlacemark.location.coordinate addressDictionary:geocodedPlacemark.addressDictionary];

        //Create a map item for geocoded address to pass to Maps app
        MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
        [mapItem setName:geocodedPlacemark.name];

        //Set Directions mode to Driving
        NSDictionary *launchOptions =    @{MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving};

        //Get the "Current User Locations" MKMapItem
        MKMapItem *currentLocationMapItem = [MKMapItem mapItemForCurrentLocation];

        //Pass the current location and destination  map items to Maps app
        [MKMapItem openMapsWithItems:@[currentLocationMapItem,  mapItem] launchOptions:launchOptions];

       }];
    }

    }

Answer 1:

有没有办法回到你的应用程序(编程),因为你是在你的应用程序不再,但在地图应用。 执行后openMapsWithItems:launchOptions: ,应用程序委托的applicationdDidEnterBackground:方法被调用。

目前还没有办法用Mapkit嵌入地图与您的应用程序内的方向。



文章来源: How to exit from Map App in IOS 6 i.e. return control back to app requesting directions?