简体   繁体   中英

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM