如何绕过ABPeoplePickerNavigationController中缺少'添加'按钮? [英] how to get around lack of 'add' button in ABPeoplePickerNavigationController?

查看:150
本文介绍了如何绕过ABPeoplePickerNavigationController中缺少'添加'按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程式需要将自订类别的实例与iPhone的AddressBook中的联络人纪录相关联。当我展示 ABPeoplePickerNavigationController 并允许用户选择现有联系人时,一切都很好,很好。问题是没有明显的方式允许用户轻松地添加联系人记录,如果他们正在寻找的不是已经在他们的地址簿中存在。

My app needs to associate instances of a custom class with contact records in the iPhone's AddressBook. Everything's all well and good when I present the ABPeoplePickerNavigationController and allow the user to pick an existing contact. Problem is there's no obvious way to allow a user to easily ADD a contact record if the one they're looking for doesn't already exist in their AddressBook.

用户从 ABPeoplePickerNavigationController ABNewPersonViewController 的方式很容易,直观的用户?

How are people getting from ABPeoplePickerNavigationController to ABNewPersonViewController in a way that's easy & intuitive for the user?

推荐答案

您可以创建一个UIBarButton并将其添加到ABPeoplePickerNavigationController的UINavigationBar。 >

You can create a UIBarButton and add it to the UINavigationBar of the ABPeoplePickerNavigationController like so.

    peoplePicker.topViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addPerson:)];

-(IBAction)addPerson:(id)sender{
    ABNewPersonViewController *view = [[ABNewPersonViewController alloc] init];
    view.newPersonViewDelegate = self;
    UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:view];
    [self.picker presentModalViewController:nc animated:YES];
}

我碰到的问题是ABPeoplePickerNavigationController有一个取消按钮在rightBarButtonItem插槽,我不得不更新导航栏上的

The issue that i came up against was that the ABPeoplePickerNavigationController has a cancel button placed in the rightBarButtonItem slot and I had to update the navigation bar on the

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{

博客,其中包含工作示例,应该允许您创建类似于iPhone上的联系人样式应用程序。希望这有助于。

I have documented the entire process on my blog with a worked example that should allow you to create a contacts style application similar to that on the iPhone. Hope this helps.

这篇关于如何绕过ABPeoplePickerNavigationController中缺少'添加'按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆