I have an app that needs to add contacts. For that I want use the CNContactViewController(forNewContact: nil) from the ContactsUI framework.
My approach to achieve this is the following
class myClass: UITableViewController, CNContactViewControllerDelegate {
// ...
@objc fileprivate func addTapped() {
print("add tapped")
let createContactcontroller = CNContactViewController(forNewContact: nil)
controller.delegate = self
navigationController?.pushViewController(controller, animated: true)
}
func contactViewController(_ viewController: CNContactViewController, didCompleteWith contact: CNContact?) {
// Service.shared.addContact(contact: contact)
}
}
But there are a few problems that I can't solve:
- The animation looks laggy.
- When the user is done with creating the contact and clicks done, than the CNContactViewController for profile (like in contacts app) is shown, instead of just returning to tableViewController. How can I modify this?
- I get following errors:
2019-11-16 10:29:48.480636+0100 Flashback[11688:541742] [Snapshotting] Snapshotting a view (0x7fc76481a420, _UIButtonBarStackView) that has not been rendered at least once requires afterScreenUpdates:YES. 2019-11-16 10:29:48.482425+0100 Flashback[11688:541742] [Snapshotting] Snapshotting a view (0x7fc76481d020, _UIButtonBarStackView) that has not been rendered at least once requires afterScreenUpdates:YES. 2019-11-16 10:29:48.484897+0100 Flashback[11688:541742] [Snapshotting] Snapshotting a view (0x7fc76481d5c0, _UIButtonBarStackView) that has not been rendered at least once requires afterScreenUpdates:YES. 2019-11-16 10:29:48.488071+0100 Flashback[11688:541742] [Snapshotting] Snapshotting a view (0x7fc76481d9f0, _UIButtonBarStackView) that has not been rendered at least once requires afterScreenUpdates:YES. 2019-11-16 10:29:48.489883+0100 Flashback[11688:541742] [Snapshotting] Snapshotting a view (0x7fc7626228e0, _UIButtonBarStackView) that has not been rendered at least once requires afterScreenUpdates:YES. 2019-11-16 10:29:48.491904+0100 Flashback[11688:541742] [Snapshotting] Snapshotting a view (0x7fc7626102d0, _UIButtonBarStackView) that has not been rendered at least once requires afterScreenUpdates:YES.