【发布时间】:2020-01-07 22:42:01
【问题描述】:
我使用 CNContactPickerViewController 使用户能够从存储在手机上的联系人列表中选择联系人。我使用 CNContactPicker 委托方法使用联系人姓名和号码。代码如下
func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) {
// You can fetch selected name and number in the following way
// user name
let userName: String = "\(contact.givenName) \(contact.familyName)"
// user phone number
let userPhoneNumbers:[CNLabeledValue<CNPhoneNumber>] = contact.phoneNumbers
let firstPhoneNumber:CNPhoneNumber = userPhoneNumbers[0].value
// user phone number string
let primaryPhoneNumberStr:String = firstPhoneNumber.stringValue
// print(primaryPhoneNumberStr)
textfieldName.text = userName
textfieldContactNo.text = primaryPhoneNumberStr
}
我想在验证后对其应用验证 -
选择的不是手机或座机号码。
检查号码是否有国家代码。
有人可以帮我进行上述验证吗?
【问题讨论】:
标签: ios swift contactpicker cncontactpicker