gpt4 book ai didi

objective-c - ABPersonViewController 完成编辑通知

转载 作者:行者123 更新时间:2023-11-29 11:23:24 24 4
gpt4 key购买 nike

根据 Apple 的快速联系人示例代码使用 ABPersonViewController。

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];

我需要一种方式来通知选择器已完成编辑或已关闭,以便我可以更新我的数据存储中的一些缓存值。

Apple 的文档建议远 ionic 类化 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 方法和委托(delegate)方法

- (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 shouldPerformDefaultActionForPerson:

关于objective-c - ABPersonViewController 完成编辑通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5414378/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com