2017-01-29 28 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:接觸)

它會爲你

工作