PDA

View Full Version : Image Picker and People Picker secret




lawicko
Jul 29, 2008, 02:21 AM
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:



kleinemans
Aug 18, 2008, 04:19 PM
It might be a little late now but you could try the following:


picker = [[ABPeoplePickerNavigationController alloc] init];

picker.peoplePickerDelegate = self;
picker.navigationBarHidden=YES;
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.

lawicko
Aug 19, 2008, 03:24 AM
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];
}