我的应用程序中有一个“ +”按钮,点击时,我想导航到“新联系人”屏幕(如下图所示)。
我在这里找到了相同的问题:iOS - add contact into Contacts?,但是代码不是最新的。 我想要Swift 5中的解决方案。
我的应用程序中有一个“ +”按钮,点击时,我想导航到“新联系人”屏幕(如下图所示)。
我在这里找到了相同的问题:iOS - add contact into Contacts?,但是代码不是最新的。 我想要Swift 5中的解决方案。
import Contacts // import these framework
import ContactsUI
//--- Your Button Action
@IBAction func buttonClick(_ sender: Any)
{
let openContact = CNContact()
let vc = CNContactViewController(forNewContact: openContact)
vc.delegate = self // this delegate CNContactViewControllerDelegate
// self.navigationController?.pushViewController(vc,animated: true)
self.present(UINavigationController(rootViewController: vc),animated:true)
}
func contactViewController(_ viewController: CNContactViewController,didCompleteWith contact: CNContact?) {
self.dismiss(animated: true,completion: nil)
}