3

我正在开发通讯录应用程序。当用户从联系人列表中选择用户时,我想直接在编辑模式下打开该记录,ABPersonViewController而不是单击编辑按钮ABPersonViewController。我怎样才能做到这一点?谢谢

4

3 回答 3

2

只需在视图显示后调用 setEditing 即可:

ABPersonViewController *ab = [[ABPersonViewController alloc] init];
ab.allowsEditing = YES;
// customize as you see fit
[self.navigationController pushViewController:ab animated:YES];
[ab setEditing:YES animated:NO];

我在 iPad 上从弹出框控制器中尝试了这个,效果很好。

于 2012-09-06T01:38:53.497 回答
1

事实上 AB New PersonViewController 在编辑模式下看起来与 ABPersonViewController 完全一样。

于 2015-10-21T12:19:31.147 回答
-2

我通过这样做完成了同样的事情:

    ABRecordID personId = (ABRecordID)contact_ID;// if you want to edit a particular record and you're maintaining contact ID somewhere in your project.
    ABPersonViewController *contactVC = [[ABPersonViewController alloc] init];
    contactVC.personViewDelegate = self;// set your ViewController as delegate
    contactVC.allowsEditing = YES; //set NO if you don't wanna allow editing
    contactVC.displayedPerson = ABAddressBookGetPersonWithRecordID(addressBook, personId);
    [self.navigationController presentViewController:contactVC animated:YES completion:nil];
于 2015-06-19T17:53:21.233 回答