//
// ViewController.m
// 跳转到设置界面
//
// Created by 上官林海 on 15/11/12.
// Copyright © 2015年 chinaByte_SGLH. All rights reserved.
//
#import "ViewController.h"
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>
@interface ViewController ()<ABPeoplePickerNavigationControllerDelegate, ABPersonViewControllerDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(100, 100, 100, 50)];
button.backgroundColor = [UIColor redColor];
[button addTarget:self action:@selector(button2) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
- (void)button2{
ABPeoplePickerNavigationController *peoplePicker = [[ABPeoplePickerNavigationController alloc] init];
peoplePicker.peoplePickerDelegate = self;
[self presentViewController:peoplePicker animated:YES completion:nil];
}
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
ABMultiValueRef valuesRef = ABRecordCopyValue(person, kABPersonPhoneProperty);
CFIndex index = ABMultiValueGetIndexForIdentifier(valuesRef,identifier);
CFStringRef value = ABMultiValueCopyValueAtIndex(valuesRef,index);
[self dismissViewControllerAnimated:YES completion:^{
// self.textField.text = (__bridge NSString*)value;
NSLog(@"%@",(__bridge NSString*)value);
}];
}