iOS7-ABPersonViewController,编辑模式

iOS7-ABPersonViewController,编辑模式,ios,ios7,addressbook,abpersonviewcontroller,Ios,Ios7,Addressbook,Abpersonviewcontroller,苹果提供了一个很好的综合性小示例“QuickContacts”(),概述了可下载的源代码如所述工作(一旦您将名为“Applesed”的人员添加到通讯簿中,或将第246行(QuickContactsViewController.m)中的人员姓名更改为通讯簿中已存在的名称) 问题: 我们如何修改函数-(void)showPersonViewController函数,使ABPersonViewController“picker”在打开时(推到导航控制器堆栈上后)已经处于编辑模式(带有可见的“Done”

苹果提供了一个很好的综合性小示例“QuickContacts”(),概述了可下载的源代码如所述工作(一旦您将名为“Applesed”的人员添加到通讯簿中,或将第246行(QuickContactsViewController.m)中的人员姓名更改为通讯簿中已存在的名称)

问题: 我们如何修改函数
-(void)showPersonViewController
函数,使
ABPersonViewController“picker”
在打开时(推到导航控制器堆栈上后)已经处于编辑模式(带有可见的“Done”编辑按钮)

在“7”之前的iOS版本中,直接插入例如
picker.editing=YES将选择器推到导航堆栈上之前,以便在其打开后在编辑模式下查看(请参阅下面的代码)

在iOS7中,这不再有效

这是iOS7中的一个bug吗?如果是,是否有简单的解决方法(而不是反向工程
ABPersonViewController
class)或者,现在需要用不同的编码吗

期待您的评论

-(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,下面是代码:

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

[self.navigationController pushViewController:picker animated:YES];

这是iOS 7中的一个bug。报告的人越多,将分配优先级越高的修复程序。@Tommie C.-你说得对,苹果确认这是一个bug。-感谢您的评论。此问题尚未解决,似乎??在协议方法-(void)newPersonViewController:didCompleteWithNewPerson:ABRecordRef person将为NULL(如果用户取消编辑)或原始值(在picker.displayedPerson=person;处初始化)