jkigel
jkigel

Reputation: 1592

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!

Upvotes: 9

Views: 2012

Answers (1)

Warif Akhand Rishi
Warif Akhand Rishi

Reputation: 24248

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;
}

Upvotes: 14

Related Questions