iOS7 – ABPersonViewController,编辑模式

苹果公司提供了一个很好的综合和小例子,“QuickContacts”( developer.apple.com/library/IOs/samplecode/QuickContacts/Introduction/Intro.html ),概述了地址簿UI框架的基本用法。 – 可下载的源代码的工作方式如下(一旦将一个名为“Appleseed”的人员添加到您的地址簿中,或将第246行(QuickContactsViewController.m)中的人员名称更改为您的地址簿中已存在的人员)。

问题:我们如何修改函数-(void)showPersonViewController函数,使得ABPersonViewController "picker" -(void)showPersonViewController ABPersonViewController "picker"已经处于编辑模式(带有可见的“完成”editingButton),当它被打开时(被推入到navigationController堆栈)。

在“7”之前的iOS版本中,插入如picker.editing = YES;是一个直接的问题picker.editing = YES; 在将拾取器推入导航堆栈之前,为了以编辑模式查看它,一旦打开(见下面的代码)。

在iOS7中,这不起作用了。

这是在iOS7中的错误,如果是这样,是否有一个简单的解决方法(而不是如反向工程的ABPersonViewController类)? – 还是需要以不同的方式进行编码?

期待您的意见。

 -(void)showPersonViewController { // Search for the person named "Appleseed" in the address book NSArray *people = (NSArray *)CFBridgingRelease(ABAddressBookCopyPeopleWithName(self.addressBook, CFSTR("Appleseed"))); // Display "Appleseed" information if found in the address book if ((people != nil) && [people count]) { ABRecordRef person = (__bridge ABRecordRef)[people objectAtIndex:0]; ABPersonViewController *picker = [[ABPersonViewController alloc] init]; picker.personViewDelegate = self; picker.displayedPerson = person; // Allow users to edit the person's information picker.allowsEditing = YES; picker.editing = YES; // in iOS6 this works, in iOS7 it does not [self.navigationController pushViewController:picker animated:YES]; } ... ... } 

您可以使用ABNewPersonViewController而不是ABPersonViewController,波纹pipe是代码:

 ABNewPersonViewController *picker = [[[ABNewPersonViewController alloc] init] autorelease]; picker.newPersonViewDelegate = self; picker.displayedPerson = person; picker.navigationItem.title=@"edit contact"; [self.navigationController pushViewController:picker animated:YES];