我正在尝试在通用应用中启用联系人编辑,ABPersonViewController
中显示UIPopoverController
。此人确实显示,但没有“编辑”按钮。实际上,如果用户已经在可编辑的表单中看到了详细信息,我会更喜欢它,但是如果他们可以在点击“编辑”按钮后进行编辑就可以了。在iPhone上,它工作正常。请有人帮帮忙。
ABPersonViewController *view = [[ABPersonViewController alloc] init];
view.personViewDelegate = self;
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef contact = ABAddressBookGetPersonWithRecordID(addressBook,(ABRecordID)recId);
view.displayedPerson = contact;
view.displayedProperties = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonFirstNameProperty], [NSNumber numberWithInt:kABPersonLastNameProperty], [NSNumber numberWithInt:kABPersonAddressProperty], nil];
view.allowsEditing = YES;
view.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back",nil) style:UIBarButtonItemStylePlain target:self action:@selector(ReturnFromPersonView)] ;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
UIPopoverController *addressPopup;
addressPopup = [[UIPopoverController alloc] initWithContentViewController:view];
addressPopup.delegate = self;
self.popoverController = addressPopup;
[addressPopup release];
[self.popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
else
{
[self.navigationController pushViewController:view animated:YES];
}
if (addressBook) CFRelease(addressBook);
[view release];
答案 0 :(得分:0)
您需要将ABPersonViewController *视图显式添加到UINavigationController。
ABPersonViewController *view = [[ABPersonViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:view];
UIPopoverController *personViewPopover = [[UIPopoverController alloc] initWithContentViewController:navController];