2

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.

Randoms
  • 2,110
  • 2
  • 20
  • 31
  • I did not manage to get both methods to get triggered, but I noticed one can access the **CNContact** from the `didSelectContactProperty` method : `contactProperty.contact` – Benoît Oct 04 '16 at 12:28

0 Answers0