2017-01-29 31 views
0

我有一个任务,在他的外观(例如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方法,但它会对用户可见。我怎么解决这个问题?谢谢。

回答

0

我得出的结论是,WhatsApp为此创建一个自定义屏幕。只是我在电报中看到了与修改设计相同的屏幕。

1

只是改变让cnContactViewController = CNContactViewController(为:接触)

让CVC = CNContactViewController(forNewContact:接触)

它会为你

工作