Oc 通讯录的使用
来源:互联网 发布:淘宝人生笔趣阁 编辑:程序博客网 时间:2024/05/20 06:08
链接】iPhone通讯录联系人的增加、删除、修改的操
http://blog.csdn.net/yongyinmg/article/details/26376905
【链接】CNContact对通讯录的基本使用(第二篇)
http://www.cnblogs.com/lantu1989/p/5469346.html
首先在工程里导入ContactsUI.framework和Contacts.framework两个框架
#import <ContactsUI/ContactsUI.h>@interface ViewController ()<CNContactPickerDelegate>@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad];}-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ //iOS 10 // AB_DEPRECATED("Use CNContactPickerViewController from ContactsUI.framework instead") CNContactPickerViewController * contactVc = [CNContactPickerViewController new]; contactVc.delegate = self; [self presentViewController:contactVc animated:YES completion:^{ }];}#pragma mark - 用户点击联系人获取方法 两个方法都写只调用此方法-(void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact{ // NSLog(@"contact : %@",contact); // 姓氏 名字 NSLog(@"name:%@%@",contact.familyName,contact.givenName); //公司名 NSLog(@"公司: %@",contact.organizationName); //获取通讯录某个人所有电话并存入数组中 需要哪个取哪个 NSMutableArray * arrMPhoneNums = [NSMutableArray array]; for (CNLabeledValue * labValue in contact.phoneNumbers) { NSString * strPhoneNums = [labValue.value stringValue]; NSLog(@"所有电话是: %@",strPhoneNums); [arrMPhoneNums addObject:strPhoneNums]; } //所有邮件地址数组 NSMutableArray * arrMEmails = [NSMutableArray array]; for (CNLabeledValue * labValue in contact.emailAddresses) { NSLog(@"email : %@",labValue.value); [arrMEmails addObject:labValue.value]; } [picker dismissViewControllerAnimated:YES completion:nil];}#pragma mark - 用户点进去获取属性调用方法 例如从通讯录选择联系人打电话两个方法都写只调用上面方法- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContactProperty:(CNContactProperty *)contactProperty{ // NSLog(@"contactProperty : %@",contactProperty); // NSLog(@"contact : %@",contactProperty.contact); // NSLog(@"key : %@",contactProperty.key); // [[UIApplication sharedApplication] openURL:url]; // NSLog(@"identifier : %@",contactProperty.identifier); // NSLog(@"label : %@",contactProperty.label); //获得点击的属性,在此进行处理... NSLog(@"value : %@",[contactProperty.value stringValue]); [picker dismissViewControllerAnimated:YES completion:nil];}- (void)contactPickerDidCancel:(CNContactPickerViewController *)picker{ [picker dismissViewControllerAnimated:YES completion:nil];}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
阅读全文
0 0
- Oc 通讯录的使用
- OC 通讯录 实现的方法
- OC -类似于通讯录的功能
- OC通讯录
- 通讯录 oc
- OC通讯录
- OC(实现中等通讯录的操作)
- OC大作业_通讯录的实现
- OC实现中等难度的通讯录
- 通讯录-AlphabetIndexer的使用
- OC实现简单通讯录
- OC简单通讯录
- OC第三题通讯录
- oc 通讯录作业题
- OC----通讯录实现
- OC实现通讯录
- OC编写中级通讯录
- 实现中等通讯录(OC)
- Apache Kylin最新的Streaming OLAP实现
- unity中关于transform的小结
- 算法面经
- NOIP模拟:乘积(状压DP)
- cmd操作本地数据库命令
- Oc 通讯录的使用
- 心好累.
- LAMP(centos6.9+httpd2.4+maria5.5.7+php5-fpm)
- Effect(二)—— fyDragRibbon
- select下拉框数据回显
- Linux 文件系统理解
- 电商某些相关依赖
- 类型转换
- 从HPC到AI,看联想的进阶之路