Posts

Post not yet marked as solved
0 Replies
642 Views
After presenting a CNContactViewController to create a new contact once I open the image editor and instead of going through the whole flow I decide the cancel it once I get back to my contact VC the cancel and done buttons are gone and I have no way to dismiss the contact info. Note: If you do go through setting an image at the end of the flow once you are back to the contacts VC the buttons are enabled again and the VC can be dismissed. Here's a quick code example of the presentation logic. This is all this app did. class ViewController: UIViewController { let button = UIButton(primaryAction: UIAction(handler: { _ in self.presentContacts() })) func presentContacts() { let mutableContact = CNMutableContact() let newPhone = CNLabeledValue(label: CNLabelPhoneNumberMobile, value: CNPhoneNumber(stringValue: "randomnumberhere")) mutableContact.phoneNumbers += [newPhone] let cont = CNContactViewController(forUnknownContact: mutableContact) cont.contactStore = CNContactStore() cont.allowsActions = false cont.isEditing = true cont.delegate = self let nav = UINavigationController(rootViewController: cont) nav.modalPresentationStyle = .fullScreen let navBarAppearance = UINavigationBarAppearance() navBarAppearance.configureWithTransparentBackground() nav.navigationBar.standardAppearance = navBarAppearance nav.navigationBar.scrollEdgeAppearance = navBarAppearance self.navigationController?.present(cont, animated: true) } } extension ViewController: CNContactViewControllerDelegate { func contactViewController(_ viewController: CNContactViewController, shouldPerformDefaultActionFor property: CNContactProperty) -> Bool { return false } func contactViewController(_ viewController: CNContactViewController, didCompleteWith contact: CNContact?) { viewController.dismiss(animated: true) } }
Posted Last updated
.