Reputation: 1068
If the text itself can't be changed and the button needs to be replaced then please also explain how to make the delegate method
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
still get called from replacement button?
Any help is greatly appreciated.
Upvotes: 1
Views: 996
Reputation: 1068
After some fiddling this worked:
Include UINavigationControllerDelegate
in object .h
file. Add the following to .m
file:
- (void) showAddressBook {
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
// use delegate to change cancel text to done on picker that pops up
picker.delegate = self;
[self presentViewController:picker animated:true completion:nil];
}
// replace button now that controller is initialized
- (void)navigationController:(UINavigationController*)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
if([navigationController isKindOfClass:[ABPeoplePickerNavigationController class]]) {
UIBarButtonItem *obbi = navigationController.topViewController.navigationItem.rightBarButtonItem;
UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:obbi.target action:obbi.action];
navigationController.topViewController.navigationItem.rightBarButtonItem = bbi;
}
}
Upvotes: 2