iOS 7 - Person ViewController,编辑模式

标签 ios ios7 addressbook abpersonviewcontroller

Apple 提供了一个很好的综合性小示例“QuickContacts”(developer.apple.com/library/IOs/samplecode/QuickContacts/Introduction/Intro.html),概述了 Address Book UI Framework 的基本用法。 . - 可下载的源代码按照描述工作(一旦您将名为“Appleseed”的人添加到您的地址簿或将第 246 行(QuickContactsViewController.m)中的人名更改为您的地址簿中已经存在的名称)。

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

在“7”之前的 iOS 版本中,只需插入例如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,下面是代码:

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 - Person ViewController,编辑模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19099071/

相关文章:

ios - UITableView insertRowsAtIndexPaths 抛出 __NSArrayM insertObject :atIndex :'object cannot be nil' error

android - 如何在 Android 上为单个联系人设置铃声?

ios - 如何将文本从 SafariViewController 快速获取到我们的应用程序?

iphone - XCode 不小心将我的项目添加到文件夹

ios - UICollectionView 在保持位置上方插入单元格(如 Messages.app)

ios7 - 新ios7中的UDID不可用(带FFFFFFFF前缀)

ios - 可选绑定(bind)的值(value)超出范围?

ios - UINavigationBar 显示为半透明而不是不透明的白色

iOS通讯录列表,只返回一组,不是全部

ios - 在 iOS 中,加载排序列表的最快方法是什么?