期望:我试图能够在 ContactsUI 中选择多个联系人,如下所示:
正如您从下面的代码中看到的,我正在使用 contactPickerView,所以我不知道我做错了什么:/
import UIKit
import ContactsUI
import Contacts
class FindContactsVC: UIViewController, CNContactPickerDelegate {
//button to open contactUI
@IBAction func contactsButton(_ sender: Any) {
let cnPicker = CNContactPickerViewController()
cnPicker.delegate = self
self.present(cnPicker, animated: true, completion: nil)
}
//Works, but only allows me to select one at a time
func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) {
print(contact.phoneNumbers)
print("WYASDFY")
}
//This function never runs :/
func contactPicker(picker: CNContactPickerViewController, didSelectContacts contacts: [CNContact]){
print(contacts)
print("plz work!")
contacts.forEach { contact in …Run Code Online (Sandbox Code Playgroud)