2011-01-27 84 views

回答

7

使用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

相关问题