我有一个任务,在他的外观(例如WhatsApp)中同时显示联系人编辑屏幕,我向他展示了以下方法。CNContactViewController set在出现之前编辑true
@objc private func presentContactEditController() {
guard var contact = contactModel.contact else { return }
if !contact.areKeysAvailable([CNContactViewController.descriptorForRequiredKeys()]) {
do {
let contactStore = CNContactStore()
contact = try contactStore.unifiedContact(withIdentifier: contact.identifier, keysToFetch: [CNContactViewController.descriptorForRequiredKeys()])
} catch {
debugPrint("presentContactEditController error", error.localizedDescription)
}
}
let cnContactViewController = CNContactViewController(for: contact)
cnContactViewController.delegate = self
cnContactViewController.setEditing(true, animated: false)
let contactNaviController = UINavigationController(rootViewController: cnContactViewController)
present(contactNaviController, animated: true, completion: nil)
}
但有一个关于此联系人信息的屏幕。所以我试图通过CNContactViewController的继承人,不同的方法ViewController
生命周期,但它只适用于viewDidAppear
方法,但它会对用户可见。我怎么解决这个问题?谢谢。