Contacts Framework
提供了一种这样的标签phoneNumbers
:
CNLabelPhoneNumberiPhone
, CNLabelPhoneNumberMain
,CNLabelPhoneNumberPager
和其他。
for contact in self.contact.phoneNumbers {
if contact.label == CNLabelPhoneNumberiPhone {
self.phoneNumberTextField.text = (contact.value as! CNPhoneNumber).stringValue
break
}
}
但它们是有限的。自定义标签没有任何选项phoneNumbers
。我可以在 上显示自定义标签phoneNumbers
吗Contacts Framework
?
` 如果 !self.contact.phoneNumbers.isEmpty {
for contact in self.contact.phoneNumbers {
switch contact.label {
case CNLabelHome:
self.phoneNumberTextField.text = (contact.value as! CNPhoneNumber).stringValue
case CNLabelWork:
self.phoneNumberTextField.text = (contact.value as! CNPhoneNumber).stringValue
case CNLabelOther:
self.phoneNumberTextField.text = (contact.value as! CNPhoneNumber).stringValue
case CNLabelPhoneNumberMain:
self.phoneNumberTextField.text = (contact.value as! CNPhoneNumber).stringValue
case CNLabelPhoneNumberiPhone:
self.phoneNumberTextField.text = (contact.value as! CNPhoneNumber).stringValue
case CNLabelPhoneNumberMobile:
self.phoneNumberTextField.text = (contact.value as! CNPhoneNumber).stringValue
case CNLabelPhoneNumberPager:
self.phoneNumberTextField.text = (contact.value as! CNPhoneNumber).stringValue
case CNLabelPhoneNumberHomeFax:
self.phoneNumberTextField.text = (contact.value as! CNPhoneNumber).stringValue
case CNLabelPhoneNumberWorkFax:
self.phoneNumberTextField.text = (contact.value as! CNPhoneNumber).stringValue
case CNLabelPhoneNumberOtherFax:
self.phoneNumberTextField.text = (contact.value as! CNPhoneNumber).stringValue
default:
self.phoneNumberTextField.text = (contact.value as! CNPhoneNumber).stringValue
break
}
}
}
`