Abpeoplepickernavigationcontroller Changes with iOS8

ABPeoplePickerNavigationController changes with iOS8?

iOS 8 requires a new delegate method be implemented for this:

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
}

Keep the old delegate method in place to support iOS 7 or earlier. What I do in my app is call the iOS 7 delegate method from the iOS 8 delegate method:

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
[self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person property:property identifier:identifier];
}

If this delegate method isn't implemented in iOS 8, tapping the value causes the action. When implemented, the delegate is called instead with the selected value.

ABPeoplePickerNavigationController changes with iOS8?

iOS 8 requires a new delegate method be implemented for this:

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
}

Keep the old delegate method in place to support iOS 7 or earlier. What I do in my app is call the iOS 7 delegate method from the iOS 8 delegate method:

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
[self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person property:property identifier:identifier];
}

If this delegate method isn't implemented in iOS 8, tapping the value causes the action. When implemented, the delegate is called instead with the selected value.

iOS 8: Cannot change the navigation bar at all of the ABPeoplePickerNavigationController

Actually, thanks to the comment above, I realized that an appearance proxy should work like so:

[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

Just put that in the viewDidLoad method of the View Controller from which you are instigating the ABPeoplePickerView. This will also work for MFMailerView as well.
My code that I'm using to style my bars properly is:

[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont
fontWithName:@"Helvetica Neue" size:12], NSFontAttributeName,
[UIColor whiteColor], NSForegroundColorAttributeName, nil];

[[UINavigationBar appearance] setTitleTextAttributes:attributes];

Cannot select contact on iOS 8

Where are you specifying the peoplePickerDelegate?

In iOS 8, if you specify peoplePickerDelegate in viewDidLoad, you will experience the curious behavior you describe (cancel delegate works, the didSelect... and shouldContinue... do not). If you specify peoplePickerDelegate immediately after init (or during), it works fine.

This would appear to be an iOS 8 "feature". I'll file a bug report.

ABPeoplePickerNavigationController with UITabBarController is not showing correctly in iOS8

Officially ABPeoplePickerNavigationController doesn't support subclassing: link here

Subclassing Notes
The ABPeoplePickerNavigationController class does not support subclassing.

However, the problem is that the view of your ABPeoplePickerNavigationController subclass is extending under the tab bar.
You can, for example, change it's size at runtime in this way

- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
CGRect rect = self.view.bounds;
rect.size.height = rect.size.height - 40;
self.view.frame = rect;
}

Note, the 40 is only an example, you should calculate the height of your tab bar controller because it can change for other screen dimensions and rotations.

Or, better, you can search for the underlying UITableView instance and set the contentInset property.

EDIT
This seems to have problems with the status bar, since the ABPeoplePickerNavigationController is unable to extend the navigation bar under the status bar if you change it's frame

In both this cases, however, your app will probably be rejected, because you are subclassing a class that explicitly forbids it.

A better and "legal" way to add it is to use a container view controller

Look at This Example

Create a new view controller, add a container view, then add the ABPeoplePickerNavigationController in this way:

-(void)viewDidLoad
{
[super viewDidLoad];

// create the ABPeoplePickerNavigationController instance
ABPeoplePickerNavigationController *controller = [[ABPeoplePickerNavigationController alloc] init];

// add a new child view controller to self
[self addChildViewController:controller];

// alert the child that it has been added to the father
[controller didMoveToParentViewController:self];

// update the child view frame to fit into the containerView
controller.view.frame = self.containerView.bounds;

// translate autoresizing mask into constraints, this is not needed but I usually do because is more pratical
[controller.view setTranslatesAutoresizingMaskIntoConstraints:YES];

// add the `ABPeoplePickerNavigationController` view to the container
[self.containerView addSubview:controller.view];

}

Even in this way ABPeoplePickerNavigationController has problems with the status bar (it doesn't extends correctly under it), so I constrained the container view to the Top Layout Guide and changed the color of the main view of ContainerViewController to fit with the color of the navigation bar



Related Topics



Leave a reply



Submit