如何在 UIPopOverController 中显示带有编辑按钮的 ABPersonViewController

发布于 2024-12-07 06:27:37 字数 1588 浏览 1 评论 0原文

我正在尝试在通用应用程序中启用联系人编辑功能,并在 UIPopoverController 中显示 ABPersonViewController。该人确实会显示,但没有“编辑”按钮。事实上,我更希望用户看到可编辑表单中已有的详细信息,但如果他们可以在点击“编辑”按钮后进行编辑,那就没问题了。在 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]; 

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

您需要将 ABPersonViewController *view 显式添加到 UINavigationController 中。

    ABPersonViewController *view = [[ABPersonViewController alloc] init];
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:view];
    UIPopoverController *personViewPopover = [[UIPopoverController alloc] initWithContentViewController:navController];

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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文