I am trying to enabling the editing of a Contact in a universal app, with a ABPersonViewController
displayed in a UIPopoverController
. The person does get displayed, but there is no Edit button. In actual fact, I would prefer it if the user saw the details already in an Editable form, but it would be ok if they could do the edit after hitting the Edit button. On the iPhone, it works fine. Can anyone help, please.
ABPersonViewController *view = [[ABPersonViewController alloc] init];
view.personViewDelegate = self;
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef contact = ABAddressBookGetPersonWithRecordID(addressBook,(ABRecordID)recId);
view.displayedPerson = contact;
view.displayedProperties = [NSArray ar开发者_JAVA百科rayWithObjects:[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];
You need to add your ABPersonViewController *view explicitly to a UINavigationController.
ABPersonViewController *view = [[ABPersonViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:view];
UIPopoverController *personViewPopover = [[UIPopoverController alloc] initWithContentViewController:navController];
精彩评论