ContactsUI(修改联系人)
来源:互联网 发布:java web用什么框架 编辑:程序博客网 时间:2024/06/02 15:14
- CNContactPickerViewController
- Required Keys
- Initializing View Controllers
- Displaying Contact Properties
- Notifying Delegate
- Contact Store
- Customizing Contact Card
- Highlighting a Property
- 实战
- 源代码
- 效果图
1 CNContactPickerViewController
CNContactPickerViewController可以显示一个联系人的相关信息、创建联系人或修改联系人。
1.1 Required Keys
/// 获取联系人使用的描述符public class func descriptorForRequiredKeys() -> CNKeyDescriptor
1.2 Initializing View Controllers
/// 通过已有联系人初始化CNContactPickerViewControllerpublic convenience init(forContact contact: CNContact)/// 未知联系人初始化CNContactPickerViewControllerpublic convenience init(forUnknownContact contact: CNContact)/// 新建联系人初始化CNContactPickerViewControllerpublic convenience init(forNewContact contact: CNContact?)
1.3 Displaying Contact Properties
/// 联系人public var contact: CNContact { get }/// 所属分组public var parentGroup: CNGroup?/// 所属集合public var parentContainer: CNContainer?/// 联系人显示的名称public var alternateName: String?/// 相关信息public var message: String?/// 可显示的属性public var displayedPropertyKeys: [AnyObject]?
1.4 Notifying Delegate
/// 代理控制可显示属性,及获取修改后的联系人weak public var delegate: CNContactViewControllerDelegate?
1.5 Contact Store
/// 联系人存储库public var contactStore: CNContactStore?
1.6 Customizing Contact Card
/// 能否修改数据public var allowsEditing: Bool // YES by default/// 是否显示打电话、发短信等按钮public var allowsActions: Bool // YES by default/// 是否显示联系人的关联联系人public var shouldShowLinkedContacts: Bool // NO by default
1.7 Highlighting a Property
/// 属性高亮public func highlightPropertyWithKey(key: String, identifier: String?)
2 实战
这里展示创建新联系人的简单需求。
2.1 源代码
//// YJContactsUIVC.swift// Contact//// CSDN:http://blog.csdn.net/y550918116j// GitHub:https://github.com/937447974/Blog//// Created by yangjun on 16/1/14.// Copyright © 2016年 阳君. All rights reserved.//import UIKitimport ContactsUI/// ContactsUI显示class YJContactsUIVC: UIViewController, CNContactViewControllerDelegate { override func viewDidLoad() { super.viewDidLoad() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } // MARK: - Action // MARK: CNContactViewController 测试 @IBAction func onClickCNContactViewController(sender: AnyObject) { // 创建或修改联系人 let vc = CNContactViewController(forNewContact: nil) vc.delegate = self self.navigationController?.pushViewController(vc, animated: true) } // MARK: - CNContactViewControllerDelegate func contactViewController(viewController: CNContactViewController, shouldPerformDefaultActionForContactProperty property: CNContactProperty) -> Bool { print(__FUNCTION__) print(property) return true } func contactViewController(viewController: CNContactViewController, didCompleteWithContact contact: CNContact?) { viewController.navigationController?.popViewControllerAnimated(true) print(__FUNCTION__) print(contact) }}
2.2 效果图
Appendix
Sample Code
Swift
Related Documentation
ContactsUI Framework Reference
Revision History
Copyright
CSDN:http://blog.csdn.net/y550918116j
GitHub:https://github.com/937447974/Blog
0 0
- ContactsUI(修改联系人)
- ContactsUI(选择联系人).md
- ContactsUI获取通讯录联系人信息 ContactsUI
- iOS 使用ContactsUI保存新联系人到系统通讯录
- 修改联系人
- ContactsUI(简介)
- 修改联系人详情
- iOS9.0 系统通讯录 ContactsUI/ContactsUI.h
- 电话本联系人匹配长度修改
- android监听系统联系人修改
- 内容观察者-联系人读取-修改
- Android手机联系人源码(添加联系人页面一个功能)修改
- ios-ContactsUI框架简单使用
- Android 调用系统联系人界面的添加联系人,添加已有联系人,编辑和修改。
- 如何监听系统联系人修改-android
- Android 匹配联系人号码长度修改方法
- 【contentprovider系列5】修改联系人信息
- Swift - 添加、修改、删除通讯录联系人
- Python之super函数
- 心得
- 普通用户忘记密码,又没有设置root密码
- 网络测试常用的命令-比较ping,tracert和pathping等命令之间的关系
- 欢迎使用CSDN-markdown编辑器
- ContactsUI(修改联系人)
- 行业研究:机器视觉产业2020年进入成熟期
- linux常用命令—— 系统设置(七)
- apache mina:SimpleIoProcessorPool
- iOS语法小结---豁然开朗
- android开源项目汇总
- Socket开发之通讯协议及处理(解决粘包问题)
- 2016年初Android开源项目总结
- 2016年技术学习目标