2009-11-18 77 views
0

我正在开发一个应用程序,我必须允许用户以编程方式编辑联系人。编辑iphone中的联系信息

我GOOGLE了一下

我发现ABPersonViewController将被使用。我无法找到如何植入它。

地址簿iPhone OS的编程指南也没有为我工作。

你能建议我这样做吗?

日Thnx提前

回答

0

好吧,我总算找到解决自己

这里是

-(IBAction)showPicker:(id) sender{ 
    ABAddressBookRef addressBook = ABAddressBookCreate(); 
    CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook); 
    ABRecordRef person = CFArrayGetValueAtIndex(allPeople,0); 
    ABPersonViewController *personController = [[ABPersonViewController alloc] init]; 
    personController.displayedPerson = person; 
    personController.addressBook = addressBook; 
    personController.allowsEditing = YES; 
    personController.personViewDelegate = self; 
    UINavigationController *contactNavController = [[UINavigationController alloc] initWithRootViewController:personController]; 
    [personController release]; 
    CFRelease(allPeople); 
    CFRelease(person); 

    [self presentModalViewController:contactNavController animated:YES];  
} 


-(void)personViewControllerDidCancel:(ABPersonViewController *)peoplePicker 
{ 
    [self dismissModalViewControllerAnimated:YES]; 
} 

-(BOOL)personViewController:(ABPersonViewController *)peoplePicker shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID) property identifier:(ABMultiValueIdentifier) identifier 
{ 
    return YES; 
}