我想以编程方式编辑联系人列表。有没有可用的API .....
答案 0 :(得分:1)
-(void)showPersonViewController:(NSString *)nameInContact
{
// Fetch the address book
ABAddressBookRef addressBook = ABAddressBookCreate();
// Search for the person in the address book
NSArray *people = (NSArray *)ABAddressBookCopyPeopleWithName(addressBook, CFSTR(nameInContact));
// Display the information if found in the address book
if ((people != nil) && [people count])
{
ABRecordRef person = (ABRecordRef)[people objectAtIndex:0];
ABPersonViewController *picker = [[[ABPersonViewController alloc] init] autorelease];
picker.personViewDelegate = self;
picker.displayedPerson = person;
// Allow users to edit the person’s information
picker.allowsEditing = YES;
[self.navigationController pushViewController:picker animated:YES];
}
else
{
// Show an alert if the person is not in Contacts
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:[NSString stringWithFormat:@"Could not find %@ in the Contacts application", nameInContact]
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil];
[alert show];
[alert release];
}
[people release];
CFRelease(addressBook);
}
答案 1 :(得分:0)
您可以通过编程方式访问联系人并使用ABAddressBook.framework编辑它们。
您可以在此处找到文档:
和编程指南: