码迷,mamicode.com
首页 > 移动开发 > 详细

iOS --调用系统通讯录

时间:2016-05-02 22:37:38      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:

// 调用系统通讯录需要遵循两个代理ABPeoplePickerNavigationControllerDelegate,UINavigationControllerDelegate
相关类为ABPeoplePickerNavigationController
// 系统通讯录自带导航栏,所有要model出来
// 初始化
    ABPeoplePickerNavigationController *peoplePicker = [[ABPeoplePickerNavigationController alloc] init];
    peoplePicker.peoplePickerDelegate = self;
    [self presentViewController:peoplePicker animated:YES completion:nil];
#pragma mark - ABPeoplePickerNavigationControllerDelegate
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
    
    ABMultiValueRef valuesRef = ABRecordCopyValue(person, kABPersonPhoneProperty);
    
    CFIndex index = ABMultiValueGetIndexForIdentifier(valuesRef,identifier);
    
    //电话号码
    
    CFStringRef telValue = ABMultiValueCopyValueAtIndex(valuesRef,index);
    //全名
    
    CFStringRef anFullName = ABRecordCopyCompositeName(person);
    
    [self dismissViewControllerAnimated:YES completion:^{
        
//        (__bridge NSString *)telValue;
//        [NSString stringWithFormat:@"%@",anFullName];


        NSLog(@"%@---%@",(__bridge NSString *)telValue,[NSString stringWithFormat:@"%@",anFullName]);
        
    }];
    

}

 

iOS --调用系统通讯录

标签:

原文地址:http://www.cnblogs.com/zhangshan/p/5453219.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!