Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ABPeoplePickerNavigationController hide cancel button

I'm subclassing ABPeoplePickerNavigationController and I was wondering how to hide the right toolbar item "Cancel"?

I've been searching but I couldn't find the right solution.

Thanks!

like image 744
jkigel Avatar asked Mar 05 '13 13:03

jkigel


1 Answers

Use <UINavigationControllerDelegate>

After ABPeoplePickerNavigationController alloc delegate it to self.

peoplePicker.delegate = self;

We will need to override an UINavigationController's delegate method.

// Called when the navigation controller shows a new top view controller via a push, pop or setting of the view controller stack.

- (void)navigationController:(UINavigationController*)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if([navigationController isKindOfClass:[ABPeoplePickerNavigationController class]])
        navigationController.topViewController.navigationItem.rightBarButtonItem = nil;
}
like image 108
Warif Akhand Rishi Avatar answered Nov 15 '22 05:11

Warif Akhand Rishi