CURRENT:我无法找到一种方法来获取表格视图单元格中的多个选择按钮
从下面的代码中我可以看到我正在使用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
for number in contact.phoneNumbers {
let phoneNumber = number.value
print("number is = \(phoneNumber)")
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
}
}
谢谢^。^
答案 0 :(得分:3)
我还没有检查过代码的其他部分,但至少,你需要正确实现第二个委托方法:
func contactPicker(picker: CNContactPickerViewController, didSelectContacts contacts: [CNContact]){
↓
func contactPicker(_ picker: CNContactPickerViewController, didSelect contacts: [CNContact]) {