Image Picker and People Picker secret

Discussion in 'iOS Programming' started by lawicko, Jul 29, 2008.

  1. lawicko macrumors member

    Jul 17, 2008
    Hi again :cool:
    For some time I was trying to get rid of 'Cancel' button in UIImagePicker and ABPeoplePickerNavigationController. Even though I previously managed to remove unnecesary stuff from ABPeoplePickerNavigationController, it looks like removing 'Cancel' button is beyond my skills :mad: No matter what I do, the cancel button is displayed on navigation bar. I tried to set RightBarButtonItem (or whatever the name) to nil for appropriate View Controllers (or should I say their Navigation items) but still no effect :( I tried to change that in init method, in viewWillAppear and every other place that may have worked, but it did not.
    This is kind of strange, because when I needed to remove Groups view from ABPeoplePickerController, I simply gained access to viewControllers array inside viewWillAppear method, and substituted it with my custom array, and it worked :confused:
    Any help is greatly appreciated :rolleyes:
  2. kleinemans macrumors newbie

    May 25, 2006
    It might be a little late now but you could try the following:

    picker = [[ABPeoplePickerNavigationController alloc] init];
    picker.peoplePickerDelegate = self;
    self.view = picker.view;
    This gets rid of the entire navigation bar, including the cancel button. If you place the picker in a navigation view you still have your own navigation bar above it.
  3. lawicko thread starter macrumors member

    Jul 17, 2008
    Thanks for the answer, but I've already found better way to get rid of the buttons. All I had to do is to set a delegate for image or people picker, and implement this method in delegate:
    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
    UIView *custom = [[UIView alloc] initWithFrame:CGRectMake(0,0,0,0)];
    UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithCustomView:custom];
    [viewController.navigationItem setRightBarButtonItem:btn animated:NO];
    [btn release];
    [custom release];

Share This Page