在iphone中编辑联系信息

时间:2009-11-18 05:25:59

标签: iphone abaddressbook

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

我用Google搜索了它

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

iPhone OS的地址簿编程指南对我来说也不起作用。

你能建议我这样做吗?

Thnx提前

1 个答案:

答案 0 :(得分: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;
}