用 Swift 编写的 ContactBook 选择器
支持 iOS 9 及更高版本
pod 'ASSwiftContactBook'
// init contact picker with custom desire subtitle
func showContactPicker {
let contactsVC = ASContactPicker(subTitle: .phone, multipleSelection: true, shouldOpenContactDetail: true)
let nav = UINavigationController(rootViewController: contactsVC)
self.present(nav, animated: true, completion: nil)
// init handler for selected contacts
contacts.didSelectContacts = { contacts in
contacts.forEach { contact in debugPrint("\(contact.firstName) \(contact.lastName)") }
}
// init handler for single contact, in case you choosed single selection
contacts.didSelectSingleContact = { contact in
debugPrint("\(contact.firstName) \(contact.phones[0].digits)")
}
}
@antons81 - Anton Stremovskiy