Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to hide the Cancel UIBarButtonItem on ABPeoplePickerNavigationControlle

I want to use the ABPeoplePickerNavigationController as tab in my tabbar, not as a modal view but for some reason the controller has hard coded a cancel button on the right of its top bar. Any way to hide it? I have tried subclassing ABPeoplePickerNavigationController and setting the self.navigationItem.rightBarButtonItemto nil, or to a new button, nothing happens. I tried setting self.navigationItem.titleView, nothing happens either.

Posted on Sep 1, 2008 9:58 AM

Reply
Question marked as Best reply

Posted on Sep 10, 2008 2:02 AM

Hi, I had the same problem some time ago. What helped me was overriding
- (void)navigationController: willShowViewController: animated:

inside this method you have to create custom IUView with frame rectangle = CGRectMake(0,0,0,0),
then create custom UIBarButtonItem, init it with custom view (use your previously created UIView), and then replace your rightBarButtonItem for coming ViewController with your new bar button item.

Btw. Why does it have to be such pain in the *** to go through such a simple tasks?
7 replies
Question marked as Best reply

Sep 10, 2008 2:02 AM in response to aapl.crox

Hi, I had the same problem some time ago. What helped me was overriding
- (void)navigationController: willShowViewController: animated:

inside this method you have to create custom IUView with frame rectangle = CGRectMake(0,0,0,0),
then create custom UIBarButtonItem, init it with custom view (use your previously created UIView), and then replace your rightBarButtonItem for coming ViewController with your new bar button item.

Btw. Why does it have to be such pain in the *** to go through such a simple tasks?

Nov 13, 2008 1:25 PM in response to HoofSC

Hi HoofSC,

You are claiming that you've managed to show ABPeoplePickerNavigationController in a tabbar. How did you manage to solve the issue with showing the ABCardViewer after a person is selected. The screen slides into view but only the background is visible. Shows the subviews only after you drag the view up or down with a touch. Some other people in this forum reported the same problem. Can you please help?

Nov 15, 2008 9:28 AM in response to rgarkov

I did this my making a proxy viewController subclass that does the following in awakeFromNib:


- (void)awakeFromNib
{
ABPeoplePickerNavigationController *nav = [[ABPeoplePickerNavigationController alloc] init];

NSMutableArray *newControllers = [NSMutableArray arrayWithArray: [self.tabBarController viewControllers]];
int index = [newControllers indexOfObject: self];

[newControllers replaceObjectAtIndex: index withObject: nav];

[self.tabBarController setViewControllers: newControllers animated: NO];
[nav release];
}


This seems to work as expected...

Matt

Jan 9, 2009 2:49 PM in response to aapl.crox

@interface PeoplePicker : ABPeoplePickerNavigationController<ABPeoplePickerNavigationControllerDelegate>
{
}

- (void)viewDidLoad
{
[super viewDidLoad];
[self setAllowsCancel : 0];
[self setAllowsCardEditing: 1];

self.peoplePickerDelegate = self
}

need some more help? let me email...


Message was edited by: eaglemay

Message was edited by: eaglemay

Mar 10, 2009 12:49 AM in response to eaglemay

Hi,
can I use your solution also for my code?

peoplePicker.navigationBar.tintColor = [UIColor colorWithRed:(102/255.0) green:(102/255.0) blue:(102/255.0) alpha:1.0];

peoplePicker.title = NSLocalizedString(@"contacts", @"contacts");

peoplePicker.tabBarItem.image = [UIImage imageNamed:@"buddieIcon.png"];

peoplePicker.peoplePickerDelegate = self;

tabBarController.viewControllers = [NSArray arrayWithObjects:favNavController, recNavController, peoplePicker, dialViewController, morNavController, nil];

???? Like:

peoplePicker setAllowsCancel : 0;
peoplePicker setAllowsCardEditing: 1;

Thanks for your help!

How to hide the Cancel UIBarButtonItem on ABPeoplePickerNavigationControlle

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.