首页 > 移动平台 > 详细

iOS --调用系统通讯录

时间:2016-05-02 22:35:58      阅读:228      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!