如何在 UIPopOverController 中显示带有编辑按钮的 ABPersonViewController
我正在尝试在通用应用程序中启用联系人编辑功能,并在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将 ABPersonViewController *view 显式添加到 UINavigationController 中。
You need to add your ABPersonViewController *view explicitly to a UINavigationController.