[英]iOS7 - ABPersonViewController, editing mode
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 . Apple提供了一个很好的综合小例子,“QuickContacts”( developer.apple.com/library/IOs/samplecode/QuickContacts/Introduction/Intro.html ),概述了通讯簿UI框架的基本用法。 - 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). - 可下载的源代码按照描述工作(一旦将名为“Appleseed”的人添加到地址簿中,或者将第246行(QuickContactsViewController.m)中的人名更改为地址簿中已存在的内容)。
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). 问题:我们如何修改函数-(void)showPersonViewController
函数,使得ABPersonViewController "picker"
-(void)showPersonViewController
ABPersonViewController "picker"
已经处于编辑模式(带有可见的“Done”editingButton),当它打开时(在被推到navigationController之后)堆)。
In iOS versions prior to "7", it was a straight-foward matter of just inserting eg picker.editing = YES;
在“7”之前的iOS版本中,只是插入例如picker.editing = YES;
这是一个直接的问题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). 在将选择器推入导航堆栈之前,为了在编辑模式下看到它,一旦打开(参见下面的代码)。
In iOS7, this does not work anymore. 在iOS7中,这不再起作用了。
Is this a bug in iOS7, if so, is there a simple work-around (rather then eg reverse-engineering the ABPersonViewController
class)? 这是iOS7中的一个错误,如果是这样,是否有一个简单的解决方法(而不是例如逆向工程ABPersonViewController
类)? - Or does it need to be coded differently, these days? - 或者它需要以不同的方式编码,这些天?
Looking forward to your comments. 期待您的评论。
-(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];
}
...
...
}
You can use ABNewPersonViewController instead of ABPersonViewController,bellow is the code : 您可以使用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];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.