ABPersonViewController

ABPersonViewController

本文介绍了iOS7 - ABPersonViewController,编辑模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apple提供了一个很好的全面小例子,QuickContacts(),概述。 - 可下载的源代码按照描述工作(一旦你将一个名为Appleseed的人添加到你的地址簿中,或者将第246行(QuickContactsViewController.m)中的人名更改为地址簿中已存在的内容)。

Apple features a nice comprehensive and small example, "QuickContacts" (developer.apple.com/library/IOs/samplecode/QuickContacts/Introduction/Intro.html), outlining the basic usage of the Address Book UI Framework. - The downloadable sourcecode works as described (once you add a person named "Appleseed" to your addressbook or change the person-name in line 246 (of QuickContactsViewController.m) to something that already exists in your addressbook).

问题:
如何修改函数 - (void)showPersonViewController 这样的函数一种方式 ABPersonViewController选择器已经处于编辑模式(带有可见的完成editButton),当它打开时(在被推到navigationController的堆栈之后)。

Question:How can we modify the function -(void)showPersonViewController function in such a way that the ABPersonViewController "picker" is already in editing-mode (with a visible "Done" editingButton), when it opens (after being pushed onto the navigationController's stack).

在7之前的iOS版本中,直接插入例如 picker.editing = YES; 在将选择器推入导航堆栈之前,为了在编辑模式下看到它,一旦打开(参见下面的代码)。

In iOS versions prior to "7", it was a straight-foward matter of just inserting e.g. picker.editing = YES; before pushing the picker onto the nav-stack, in order to see it in editing-mode, once it opens (see code below).

在iOS7中,这不再起作用。

In iOS7, this does not work anymore.

这是iOS7中的错误,如果是这样,是否有简单的解决方法(而不是逆向工程 ABPersonViewController 类)? - 或者它需要以不同的方式编码,这些天?

Is this a bug in iOS7, if so, is there a simple work-around (rather then e.g. reverse-engineering the ABPersonViewController class)? - Or does it need to be coded differently, these days?

期待您的评论。

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

You can use ABNewPersonViewController instead of ABPersonViewController,bellow is the code :

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

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

这篇关于iOS7 - ABPersonViewController,编辑模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 13:18