我正在开发一个应用程序,我需要在其中显示联系人应用程序中的联系人。
我已成功实现了该功能,但现在我只需要显示在本机联系人应用程序中选择的类似Magic Jack(http://itunes.apple.com/us/app/free-calls-with-magicjack/id463926997?mt=8)iPhone应用程序的组中的联系人。
我试图搜索谷歌,论坛,苹果的文档,但无法找到解决方案。任何人都可以帮助我吗?
我使用下面的代码来获取所有联系信息。
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef source = ABAddressBookCopyDefaultSource(addressBook);
NSArray *persons = (NSArray *)(ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, source, kABPersonSortByFirstName));
答案 0 :(得分:0)
以下是您可以使用的代码,它会获取姓名。
-(IBAction)handlingClick:(id)sender
{
ABPeoplePickerNavigationController *peopleController = [[ABPeoplePickerNavigationController alloc] init];
peopleController.peoplePickerDelegate = self;
[self presentModalViewController:peopleController animated:YES];
[peopleController release];
}
-(void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
{
[peoplePicker dismissModalViewControllerAnimated:YES];
}
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
return NO;
}
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
self.firstName.text = (NSString*)ABRecordCopyValue(person, kABPersonFirstNameProperty);
self.lastName.text = (NSString*)ABRecordCopyValue(person, kABPersonLastNameProperty);
[self dismissModalViewControllerAnimated:YES];
return NO;
}
答案 1 :(得分:0)
ABGroupCopyArrayOfAllMembers不适合你想要的吗?