7 Replies Latest reply: Mar 10, 2009 12:49 AM by akandor
aapl.crox Level 1 Level 1 (0 points)
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.
  • 1. Re: How to hide the Cancel UIBarButtonItem on ABPeoplePickerNavigationContr
    lawicko Level 1 Level 1 (25 points)
    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?
  • 2. Re: How to hide the Cancel UIBarButtonItem on ABPeoplePickerNavigationContr
    HoofSC Level 1 Level 1 (0 points)
    Could you suggest how you would put the ABPeoplePickerNavigationController in a tab bar view?

    I keep running into problems using IB. So darn complicated.

    Thanks in advance.
  • 3. Re: How to hide the Cancel UIBarButtonItem on ABPeoplePickerNavigationContr
    HoofSC Level 1 Level 1 (0 points)
    I managed to get the picker in the tab view, but I don't quite follow your steps in the (void)navigationController:willShowViewController:animated:

    ?
  • 4. Re: How to hide the Cancel UIBarButtonItem on ABPeoplePickerNavigationContr
    rgarkov Level 1 Level 1 (0 points)
    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?
  • 5. Re: How to hide the Cancel UIBarButtonItem on ABPeoplePickerNavigationContr
    MattBrandt Level 1 Level 1 (0 points)
    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
  • 6. Re: How to hide the Cancel UIBarButtonItem on ABPeoplePickerNavigationContr
    eaglemay Level 1 Level 1 (0 points)
    @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
  • 7. Re: How to hide the Cancel UIBarButtonItem on ABPeoplePickerNavigationContr
    akandor Level 1 Level 1 (0 points)
    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!