开发者

how can I display a ABPersonViewController with Edit button in a UIPopOverController

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜