ios开发 通信录AddressBook.framework

调用通讯录之前 先应导入两个工具包   AddressBook.framework 和AddressBookUI.framework;
  1. #import <UIKit/UIKit.h>
  2. #import <AddressBook/AddressBook.h>
  3. #import <AddressBookUI/AddressBookUI.h>

  4. @interface YourClass : UIViewController<ABPeoplePickerNavigationControllerDelegate>
  5. @end



  6. #import <YourClass.h>


  7. @implementation YourClass

  8. -(void)onClickButtonUIButton *)sender{
  9.     进入通讯录的事件   

  10.     ABPeoplePickerNavigationController *peoplePicker = [[ABPeoplePickerNavigationController alloc] init];
  11.     peoplePicker.peoplePickerDelegate = self;
  12.     [self.navigationController presentModalViewController:peoplePicker animated:YES ];

  13. }
复制代码
  1. - (BOOL)peoplePickerNavigationControllerABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPersonABRecordRef)person

  2. {

  3.     ABMutableMultiValueRef phoneMulti = ABRecordCopyValue(person, kABPersonPhoneProperty);
  4.     ABMutableMultiValueRef address=ABRecordCopyValue(person, kABPersonAddressProperty);
  5.     ABMutableMultiValueRef birthday=ABRecordCopyValue(person, kABPersonBirthdayProperty);
  6.     ABMutableMultiValueRef creationDate=ABRecordCopyValue(person, kABPersonCreationDateProperty);
  7.     ABMutableMultiValueRef date=ABRecordCopyValue(person, kABPersonDateProperty);
  8.     ABMutableMultiValueRef department=ABRecordCopyValue(person, kABPersonDepartmentProperty);
  9.     ABMutableMultiValueRef email=ABRecordCopyValue(person, kABPersonEmailProperty);
  10.     ABMutableMultiValueRef firstNamePhonetic=ABRecordCopyValue(person, kABPersonFirstNamePhoneticProperty);
  11.     ABMutableMultiValueRef firstName=ABRecordCopyValue(person, kABPersonFirstNameProperty);
  12.     ABMutableMultiValueRef instantMessage=ABRecordCopyValue(person, kABPersonInstantMessageProperty);
  13.     ABMutableMultiValueRef jobTitle=ABRecordCopyValue(person, kABPersonJobTitleProperty);
  14.     ABMutableMultiValueRef kind=ABRecordCopyValue(person, kABPersonKindProperty);
  15.     ABMutableMultiValueRef lastNamePhonetic=ABRecordCopyValue(person, kABPersonLastNamePhoneticProperty);
  16.     ABMutableMultiValueRef lastName=ABRecordCopyValue(person, kABPersonLastNameProperty);
  17.     ABMutableMultiValueRef middleNamePhonetic=ABRecordCopyValue(person, kABPersonMiddleNamePhoneticProperty);
  18.     ABMutableMultiValueRef middleName=ABRecordCopyValue(person, kABPersonMiddleNameProperty);
  19.     ABMutableMultiValueRef modificationDate=ABRecordCopyValue(person, kABPersonModificationDateProperty);
  20.     ABMutableMultiValueRef nickname=ABRecordCopyValue(person, kABPersonNicknameProperty);
  21.     ABMutableMultiValueRef note=ABRecordCopyValue(person, kABPersonNoteProperty);
  22.     ABMutableMultiValueRef organization=ABRecordCopyValue(person, kABPersonOrganizationProperty);
  23.     ABMutableMultiValueRef phone=ABRecordCopyValue(person, kABPersonPhoneProperty);
  24.     ABMutableMultiValueRef prefix=ABRecordCopyValue(person, kABPersonPrefixProperty);
  25.     ABMutableMultiValueRef relatedNames=ABRecordCopyValue(person, kABPersonRelatedNamesProperty);
  26.     ABMutableMultiValueRef socialProfile=ABRecordCopyValue(person, kABPersonSocialProfileProperty);
  27.     ABMutableMultiValueRef personSuffix=ABRecordCopyValue(person, kABPersonSuffixProperty);
  28.     ABMutableMultiValueRef _URL=ABRecordCopyValue(person, kABPersonURLProperty);





  29.     NSMutableArray *phones = [[NSMutableArray alloc] init];


  30. //    int i;

  31.     for (int i = 0; i < ABMultiValueGetCount(phoneMulti); i++) {

  32.         NSString *aPhone = [(NSString*)ABMultiValueCopyValueAtIndex(phoneMulti, i) autorelease];

  33.         [phones addObject:aPhone];

  34.     }

  35.       NSLog(@"+qqqqqqqqqq++++%@",phones);


  36.     NSLog(@"****************");
  37.     NSString *mobileNo = [phones objectAtIndex:0];

  38. //    self.label.text = (NSString*)ABRecordCopyCompositeName(person);
  39.     NSLog(@"++++++++++++++++++++%@",mobileNo);

  40.            [self dismissModalViewControllerAnimated:YES];

  41.     [peoplePicker release];

  42.     return NO;

  43. }
复制代码
  1. - (BOOL)peoplePickerNavigationControllerABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPersonABRecordRef)person propertyABPropertyID)property identifierABMultiValueIdentifier)identifier

  2. {


  3.     [self dismissModalViewControllerAnimated:YES];

  4.     [peoplePicker release];

  5.     return NO;

  6. }



  7. - (void)peoplePickerNavigationControllerDidCancelABPeoplePickerNavigationController *)peoplePicker

  8. {

  9.     [self dismissModalViewControllerAnimated:YES];

  10.     [peoplePicker release];

  11. }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值