Objective c ABPersonViewController已完成编辑通知
根据Apple的Quick Contacts示例代码使用ABPersonViewControllerObjective c ABPersonViewController已完成编辑通知,objective-c,ios,addressbook,Objective C,Ios,Addressbook,根据Apple的Quick Contacts示例代码使用ABPersonViewController ABRecordRef person = (ABRecordRef)[people objectAtIndex:0]; ABPersonViewController *picker = [[[ABPersonViewController alloc] init] autorelease]; picker.personViewDelegate = self; picker.
ABRecordRef person = (ABRecordRef)[people objectAtIndex:0];
ABPersonViewController *picker = [[[ABPersonViewController alloc] init] autorelease];
picker.personViewDelegate = self;
picker.displayedPerson = person;
picker.allowsEditing = YES;
[self.navigationController pushViewController:picker animated:YES];
我需要一种方式来通知选择器已完成编辑或已关闭,以便我可以更新数据存储中的一些缓存值
苹果的文档建议不要将ABPersonViewController子类化。非常感谢您的任何建议
ABPersonViewController *personViewController = [[ABPersonViewController alloc] init];
personViewController.personViewDelegate = self;
personViewController.displayedPerson = person;
personViewController.allowsEditing=YES;
personViewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back",nil) style:UIBarButtonItemStylePlain target:self action:@selector(ReturnFromPersonView)] ;
[self.navigationController pushViewController:personViewController animated:YES];
[personViewController release];
然后编写您的ReturnFromPersonView方法和委托方法
- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue
{
// you can write you code here with [self.navigationController popViewControllerAnimated:YES];
return YES;
}
如果您不喜欢“后退按钮”方法-您可以将代码直接写入personViewController ShouldPerformanceDefaultActionforPerson:谢谢:)我通过最小化核心数据中的冗余存储(仅保留记录ID以供参考)来避免此问题以及在需要时检索通讯簿值以维护最新的值。