I've realized that if I use the delegate method contactPicker:didSelectContact
to present a custom CNContactViewController
, the method contactPicker:didSelectContactProperty
is no longer called.
func openPicker() {
let picker = CNContactPickerViewController()
picker.delegate = self
self.presentViewController(picker, animated: true, completion: nil)
}
func contactPicker(picker: CNContactPickerViewController, didSelectContact contact: CNContact) {
//contactPicker:didSelectContactProperty works when this method is commented out
let controller = CNContactViewController(forContact: contact)
controller.delegate = self
self.navigationController?.pushViewController(controller, animated: true)
}
func contactViewController(viewController: CNContactViewController, shouldPerformDefaultActionForContactProperty property: CNContactProperty) -> Bool {
return false
}
func contactPicker(picker: CNContactPickerViewController, didSelectContactProperty contactProperty: CNContactProperty) {
print("selected contact property")
}
How can I present a custom CNContactViewController
and be notified when a user selects a property?
Using contactViewController:shouldPerformDefaultActionForContactProperty
to record the selected data does work, but it seems like an abuse of that method.