如何通过单点触摸将联系人添加到iPhone地址簿?

问题描述:

我需要能够通过单击方式访问地址簿,并在我的项目中添加/修改/删除。我会怎么做?如何通过单点触摸将联系人添加到iPhone地址簿?

使用ABAddressBook。下面是添加了姓名,地址和电话

 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(); 
+0

啊。完善。谢谢! – 2011-01-28 01:35:52

+0

你将如何撤回特定的电话号码....就像“移动”? – BRogers 2013-02-25 21:26:35

任何有兴趣新联系人的例子,我创建了一个样本项目输入查询与随机电话号码,地址簿中的联系人。希望这有助于其他人。

https://github.com/ayoung/monotouch-generate-contacts