我正在开发一个应用程序,我必须允许用户以编程方式编辑联系人。
我用谷歌搜索了它
我发现将使用 ABPersonViewController。我无法找到如何实施它。
iPhone OS 的地址簿编程指南对我也不起作用。
你能建议我这样做的方法吗?
提前谢谢
我正在开发一个应用程序,我必须允许用户以编程方式编辑联系人。
我用谷歌搜索了它
我发现将使用 ABPersonViewController。我无法找到如何实施它。
iPhone OS 的地址簿编程指南对我也不起作用。
你能建议我这样做的方法吗?
提前谢谢
好的,最后我必须自己找到解决方案
就这个
-(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;
}