CNContact联系框架ios 9.0

时间:2016-06-22 19:38:54

标签: ios9 cncontact

我可以使用以下代码

导出自定义联系人标签
    let contactStore = CNContactStore()
    let newContact = CNMutableContact()

    newContact.givenName = "Save"
    newContact.familyName = "Contact"
    newContact.phoneNumbers = [CNLabeledValue(
               label:"Mobile1",
    value:CNPhoneNumber(stringValue:"(498) 101-1123"))]
    do {
        let saveRequest = CNSaveRequest()
        saveRequest.addContact(newContact, toContainerWithIdentifier: nil)
        try contactStore.executeSaveRequest(saveRequest)
    }
    catch {
        NSLog("not saved")
    }

直到iOS 7.0 / 8.0 AddressBook:ABMultiValueAddValueAndLabel被允许自定义标签。 它似乎总是与家庭或工作标签类型保存。有人试过吗? app可以保存自定义标签而不是通用标签吗?

CONTACTS_EXTERN NSString * const CNLabelPhoneNumberiPhone                NS_AVAILABLE(10_11, 9_0);
CONTACTS_EXTERN NSString * const CNLabelPhoneNumberMobile                NS_AVAILABLE(10_11, 9_0);
CONTACTS_EXTERN NSString * const CNLabelPhoneNumberMain                  NS_AVAILABLE(10_11, 9_0);
CONTACTS_EXTERN NSString * const CNLabelPhoneNumberHomeFax               NS_AVAILABLE(10_11, 9_0);
CONTACTS_EXTERN NSString * const CNLabelPhoneNumberWorkFax               NS_AVAILABLE(10_11, 9_0);
CONTACTS_EXTERN NSString * const CNLabelPhoneNumberOtherFax              NS_AVAILABLE(10_11, 9_0);
CONTACTS_EXTERN NSString * const CNLabelPhoneNumberPager                 NS_AVAILABLE(10_11, 9_0);
CONTACTS_EXTERN NSString * const CNLabelHome                             NS_AVAILABLE(10_11, 9_0);
CONTACTS_EXTERN NSString * const CNLabelWork                             NS_AVAILABLE(10_11, 9_0);
CONTACTS_EXTERN NSString * const CNLabelOther                            NS_AVAILABLE(10_11, 9_0);

0 个答案:

没有答案