将电话号码添加到iPhone联系人-但不能替换! [英] Adding phone number to iphone contact - but NOT replacing!
问题描述
我试图复制在文本字段中点击并按住电话号码链接时iphone出现的行为,您会得到一个菜单创建新联系人"和添加到现有联系人".除了一件事情,我有这项工作.在添加到现有的" Apple实现中,如果已经有家庭联系人,则只添加另一个.它不会代替它.这样您就可以拥有多个家庭电话号码.
I am trying to replicate the behavior that the iphone that happens when you tap and hold on a phone number link in a text field you get a menu "create new contact" and "add to existing contact". I have this working except for one thing. In the "add to existing" apple implementation if there is already a home contact, it just adds another one. It doesn't REPLACE it. So you can have multiple home phone numbers.
在我的实现中,它代替了它.那么如何添加无损电话号码呢?
In my implementation it replaces it. So how do I do a not-destructive phone number add?
这是我的代码:
+(void)updatePhone:(ABRecordRef)person phone:(NSString*)phone{
ABMutableMultiValueRef phoneNumberMultiValue = ABMultiValueCreateMutable(kABPersonPhoneProperty);
ABMultiValueAddValueAndLabel(phoneNumberMultiValue, phone, kABPersonPhoneMobileLabel, NULL);
ABRecordSetValue(person, kABPersonPhoneProperty, phoneNumberMultiValue, nil);
}
有什么想法吗?
推荐答案
您尝试查询现有电话号码,然后添加新电话号码吗?
Did you try querying for the existing phone numbers, and then adding your new one?
类似这样的东西(代码未经测试):
Something like this (code not tested):
+(void)updatePhone:(ABRecordRef)person phone:(NSString*)phone{
ABMutableMultiValueRef phoneNumberMultiValue = ABMultiValueCreateMutableCopy (ABRecordCopyValue(person, kABPersonPhoneProperty));
ABMultiValueAddValueAndLabel(phoneNumberMultiValue, phone, kABPersonPhoneMobileLabel, NULL);
ABRecordSetValue(person, kABPersonPhoneProperty, phoneNumberMultiValue, nil);
}
这篇关于将电话号码添加到iPhone联系人-但不能替换!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!