Search code examples
iphoneiphone-sdk-3.0addressbookcontacts

How to add contact from within an iPhone app?


I am looking to keep track of people in my iPhone app - either adding them from existing contact data, or prompting the user to enter a new contact which will be saved to their Contacts.

I know I can create a persons record add write it to the Contact book, is it possible to display this screen?
Or do I have to implement my own view to facilitate creating a contact entry?

Screenshot of the New Contact screen on an iPhone


Solution

  • Apple provides ABNewPersonViewController. If you'd like some sample code, see Quick Contacts, in particular, this section:

    ABNewPersonViewController *picker = [[ABNewPersonViewController alloc] init];
    picker.newPersonViewDelegate = self;
    
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:picker];
    [self presentModalViewController:navigation animated:YES];
    
    [picker release];
    [navigation release];