Search code examples
iphoneios6mapkit

Trouble to dismiss MapKit iOS6


I use this code to create driving mode directions in iOS6:

Class itemClass = [MKMapItem class];

    if (itemClass && [itemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)]) {
        MKMapItem *currentLocationItem = [MKMapItem mapItemForCurrentLocation];
        NSString *Latitude = [[_locationString componentsSeparatedByString:@","] objectAtIndex:0];
        NSString *Longitude = [[_locationString componentsSeparatedByString:@","] objectAtIndex:1];
        MKPlacemark *place = [[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake([Latitude doubleValue], [Longitude doubleValue]) addressDictionary:nil];
        MKMapItem *destinamtionLocItem = [[MKMapItem alloc] initWithPlacemark:place];

        destinamtionLocItem.name = _titleString;

        NSArray *mapItemsArray = @[currentLocationItem, destinamtionLocItem];
        NSDictionary *dictForDirections = @{MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving};

        [MKMapItem openMapsWithItems:mapItemsArray launchOptions:dictForDirections];
}

The problem is that the navigationBar is always hidden and any button dismiss the view back to your application. So, How to dismiss the MapKit drivingMode?

enter image description here


Solution

  • You've misunderstood what openMapsWithItems is doing. The user is no longer in your app. You've sent them over to Apple's Map.app. The only way to dismiss it is for the user to press the home button.