我使用CNContactPickerViewController让用户选择他/她的某个联系人的电子邮件
let contactPicker = CNContactPickerViewController()
contactPicker.delegate = self
contactPicker.predicateForSelectionOfContact = NSPredicate(format: "emailAddresses.@count > 0")
contactPicker.displayedPropertyKeys = [CNContactNicknameKey, CNContactEmailAddressesKey]
选择联系人后,选择器将被解除,我保存所选邮件:
func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) {
if let _mail = contact.emailAddresses.first?.value as String? {
self.personWasSelected(with: _mail)
}
}
目前使用' predicateForSelectionOfContact'我没有邮件就禁用了联系人。但是有可能只是隐藏那些没有邮件的联系人并禁用已经选择的邮件吗?那么用户又不会再次选择它们了?