如何解决缺少' add'的问题ABPeoplePickerNavigationController中的按钮? [英] how to get around lack of 'add' button in ABPeoplePickerNavigationController?

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

问题描述

我的应用程序需要将自定义类的实例与iPhone的通讯录中的联系人记录相关联.当我显示 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{

我已经在博客上用

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.

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

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