Apple提供了一个很好的综合小例子,"QuickContacts"(developer.apple.com/library/IOs/samplecode/QuickContacts/Introduction/Intro.html),概述了通讯簿UI框架的基本用法. - 可下载的源代码按照描述工作(一旦将名为"Appleseed"的人添加到地址簿中,或者将第246行(QuickContactsViewController.m)中的人名更改为地址簿中已存在的内容).
问题:
我们如何修改功能-(void)showPersonViewController函数ABPersonViewController "picker",使其在打开时(在被推送到navigationController的堆栈之后)已经处于编辑模式(具有可见的"完成"editButton).
在"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 = …Run Code Online (Sandbox Code Playgroud) 我想实现类似于Apple自己的联系人应用程序的详细视图的视图,其中显示名称,电话号码,注释等及其编辑模式.
你能剖析整个观点是如何完成的吗?该视图是使用UITableView还是UIScrollView完成的?
以下代码在iOS7中正常工作,但在iOS8中无法正常工作(变量recordID设置正确):
CFErrorRef error = nil;
const ABAddressBookRef addressBook = (ABAddressBookCreateWithOptions (NULL, &error));
ABRecordRef contactRef = ABAddressBookGetPersonWithRecordID (addressBook, recordID);
ABPersonViewController *personViewController = [[ABPersonViewController alloc] init];
personViewController.addressBook = addressBook;
personViewController.displayedPerson = contactRef;
CFRelease(addressBook);
NSArray *displayedProperties = @[@(kABPersonFirstNameProperty),
@(kABPersonLastNameProperty),
@(kABPersonMiddleNameProperty),
@(kABPersonPrefixProperty),
@(kABPersonSuffixProperty),
@(kABPersonOrganizationProperty),
@(kABPersonJobTitleProperty),
@(kABPersonDepartmentProperty),
@(kABPersonEmailProperty),
@(kABPersonBirthdayProperty),
@(kABPersonKindProperty),
@(kABPersonAddressProperty),
@(kABPersonPhoneProperty),
@(kABPersonInstantMessageProperty),
@(kABPersonURLProperty),
@(kABPersonSocialProfileProperty),
@(kABPersonNoteProperty)];
personViewController.displayedProperties = displayedProperties;
personViewController.navigationItem.title = NSLocalizedString(@"CONTACT_DETAILS", nil);
personViewController.allowsActions = YES;
personViewController.allowsEditing = YES; // if NO, no back button is shown
personViewController.personViewDelegate = self;
personViewController.navigationItem.backBarButtonItem = [[UIBarButtonItem …Run Code Online (Sandbox Code Playgroud) 当我显示时ABPersonViewController,我需要一个按钮,允许我将其关闭并返回上一个屏幕.我该如何添加?