I am trying to customise ABPeoplePickerNavigationController
's navigation bar, by adding custom UIBarButtonItem
as left and right barbuttonitem of UINavigationController
's top view controller. This feature was working fine in iOS7 and previous versions, but not in iOS 8.
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
navigationController.topViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addNewContact:)];
navigationController.topViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel:)];
}
The above code is being executed, but it has no effect. The PeoplePickerNavigationController shows its default navigation bar, with its default items Groups and Cancel buttons.
What has changed in iOS 8? Do i need to re-implement, what I have already done?
Edit:
I logged the top ViewController in the navigation stack. It is called CNContactPicker
.
A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.
From Settings, tap Display, and then tap Navigation bar. Make sure Buttons is selected, and then you can choose your desired button setup at the bottom of the screen. Note: This option will also affect the location you swipe when using Swipe gestures.
Go to the ViewController. swift file and add the ViewDidAppear method. a nav helper variable which saves typing. the Navigation Bar Style is set to black and the tint color is set to yellow, this will change the bar button items to yellow.
I'll take a shot:
In ios 8 I believe Apple has made this into an extension somehow. That means the code is the Contacts app's. It's probably running in another context.
I think this because I read that you no longer need to ask the user for contact list access to use these pickers. That must mean that they're not really part of your own app, i.e. an extension.
There might be a way to prevent this. My bet is that you'd have to pass an ABAddressBook to the picker to do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With