- iOS10中 ABPeoplePickerNavigationController()已被弃用,现在使用的是CNContactPickerViewController, 注意在info.plist中加上访问权限Privacy - Contacts Usage Description ,value自行设定
import ContactsUI
override func viewDidLoad() {
super.viewDidLoad()
let pickerVC = CNContactPickerViewController()
pickerVC.delegate = self
self.present(pickerVC, animated: true, completion: nil)
}
func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) {
PrintLog(contact.familyName)
PrintLog(contact.givenName)
PrintLog(contact.phoneNumbers)
for i in contact.phoneNumbers {
let phoneNum = i.value.stringValue
PrintLog(phoneNum)
}
}