iOS 调用系统自带的通讯录
2015-11-12 14:48
579 查看
//
// 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);
}];
}
// 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);
}];
}
相关文章推荐
- ios多线程初步研究
- iOS_ NSUserDefaults_数据本地化的轻型装备
- iOS 键盘自适应(IQKeyboardManager)使用小结
- iOS 开始
- iOS9的一些适配
- iOS9的一些适配
- iOS PCH文件
- iOS使用推送流程
- iOS, ViewControl的生命周期
- iOS中三种数据存储(本地持久化),cell是手写创建和stroyboard或者xib创建的初始化的方法
- IOS四种保存文件的方式
- iOS中tableView的三种刷新方法
- iOS中Quartz2D
- iOS工程路径,路径宏
- iOS中Main函数作用,xcode7数据显示,自己设置主窗口
- IOS 开发,调用打电话,发短信,打开网址
- iOS中unicode 转汉字
- iOS开发 - 控制在生命周期内只运行一次
- ios 高斯模糊
- IOS代码混淆