連絡先を表す一部のセル(データに電話番号と名前があります)のコレクションビューがあり、その連絡先をiPhoneの連絡先に追加しようとしています。私は、ナビゲーションコントローラにCollectionViewCell
の内部にある「連絡先を追加」というボタンからセグを作成し、その識別子を「ADD_CONTACT」と設定しました。
ストーリーボードでは、私のsegueにはルートコントローラーのないナビゲーションコントローラーがあります。 は、デリゲートが私のUICollectionView
ビューコントローラのprepareToSegue
に私はこのコードを書いた:セットアップナビゲーションコントローラCNContactViewControllerの黒い画面としてコントローラを表示
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == ADD_CONTACT {
let dest = segue.destination as! UINavigationController
if let cell = sender as? SBInstructionCell {
if cell.isContact {
let newContact = CNMutableContact()
if let phone = cell.instructionBean?.contactAttachment?.phoneNumber{
newContact.phoneNumbers.append(CNLabeledValue(label: "home", value: CNPhoneNumber(stringValue: phone)))
}
if let name = cell.instructionBean?.contactAttachment?.contactName {
newContact.givenName.append(name)
}
let contactVC = CNContactViewController(forNewContact: newContact)
contactVC.contactStore = CNContactStore()
contactVC.delegate = self
dest.setViewControllers([contactVC], animated: false)
}
}
}
}
これは黒い画面になります。 これをどのように修正できますか?私は見たいと思っていますCNContactViewController