日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Oc 通讯录的使用

發布時間:2023/12/10 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Oc 通讯录的使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

鏈接】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

總結

以上是生活随笔為你收集整理的Oc 通讯录的使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。