Address Book and Map Kit

I am writing an application for iPhone iOS 3.0 where I want to use the Map Kit and the Address Book together. I have a database of places (e.g. restaurants) with name, location, phone, address and some other data. I list them in the form of a table, and when I select some place, I want to show the address book (using ABUnknownPersonViewController) containing all the information, so it’s easy for the user to add this contact to the address book.

Now, when I click on the address, the application switches me to the Maps application. How can I catch this event to show it in mine MKMapView(in my application inside)?

Another related question. Is there a way to implement the "Direction from here", "Direction here" buttons in the standard address book controller, for example, in the "Maps" application?

+3
source share
2 answers

Regarding the related question, from here and here, you can use the URL http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f , where you replace% f with latitude and longitude start address (saddr) and destination address (daddr) as you wish. You can choose "here" from the latitude and longitude of the user's location. This link will open in the Maps application by default, but will display directions. NTN

0

ABUnknownPersonViewController, :

// ABUnknownPersonViewControllerDelegate protocol conformance
- (BOOL)unknownPersonViewController:(ABUnknownPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
    // Allow the default action to occur.
    BOOL shouldPerformDefaultAction = YES;

    // If address property was selected, do not switch to the Maps.app.
    if (property == kABPersonAddressProperty)
    {
        [self.navigationController popViewControllerAnimated:YES];

        // Do not perform the default action    
        shouldPerformDefaultAction = NO;

        // Show your MKMapView here
        // ....
    }

    return shouldPerformDefaultAction;
}
0

Source: https://habr.com/ru/post/1714398/


All Articles