APAddressBook
APAddressBook copied to clipboard
How do I display an APContact using ABPersonViewController?
How do I display an APContact using ABPersonViewController?
Or can APAddressBook supply me with a built in controller? What are my options here? I just want to use some pre-built controller that shows me the details of a single APContact. Can this be done?
Unfortunately, there are no any UI in 'APAddressBook' and it don't compatible with any out-of-the-box solutions like 'ABPersonViewController'
I found a way to do it!
let apContact: APContact = ...
let recordId = ABRecordID(apContact.recordID.intValue)
let ab = ABAddressBookCreateWithOptions(nil, nil).takeRetainedValue()
let abRecord = ABAddressBookGetPersonWithRecordID(ab, recordId).takeUnretainedValue()
let controller = ABPersonViewController()
controller.displayedPerson = abRecord
navigationController?.pushViewController(controller, animated: true)
Looks good!