本文介绍了如何使用monotouch将联系人添加到iPhone地址簿?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要能够在monotouch中访问地址簿,并在我的项目中添加/修改/删除。我该怎么做?
I need to be able to access the address book in monotouch and add/modify/delete from there within my project. How would I do that?
推荐答案
使用ABAddressBook。以下是添加名称,地址和电话的新联系人的示例
Use ABAddressBook. Here's an example of adding a new contact with a name, address and phone
ABAddressBook ab = new ABAddressBook();
ABPerson p = new ABPerson();
p.FirstName = fname;
p.LastName = lname;
ABMutableMultiValue<string> phones = new ABMutableStringMultiValue();
phones.Add(phone, ABPersonPhoneLabel.Mobile);
p.SetPhones(phones);
ABMutableDictionaryMultiValue addresses = new ABMutableDictionaryMultiValue();
NSMutableDictionary a = new NSMutableDictionary();
a.Add(new NSString(ABPersonAddressKey.City), new NSString(city));
a.Add(new NSString(ABPersonAddressKey.State), new NSString(state));
a.Add(new NSString(ABPersonAddressKey.Zip), new NSString(zip));
a.Add(new NSString(ABPersonAddressKey.Street), new NSString(addr1));
addresses.Add(a, new NSString("Home"));
p.SetAddresses(addresses);
ab.Add(p);
ab.Save();
这篇关于如何使用monotouch将联系人添加到iPhone地址簿?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!