A replacement for ABPeoplePickerNavigationController that supports UILocalizedIndexedCollation
###Present ABPersonViewController on select
###Send group emails on return
###Custom Multiple Select
- Supports multilingual indexing and sorting by implementing UILocalizedIndexedCollation using LRIndexedCollationWithSearch.
- Supports searching by name, emails and addresses. The results are displayed using UISearchController in iOS 8.
- Supports multiple selection.
- Supports field mask for filtering contacts.
You can install ZLPeoplePickerViewController
through CocoaPods adding the following to your Podfile:
pod 'ZLPeoplePickerViewController'
Check out the demo app for an example.
ZLPeoplePickerViewController can be initialized and pushed to navigation controller like this:
self.peoplePicker = [[ZLPeoplePickerViewController alloc] init];
self.peoplePicker.delegate = self;
[self.navigationController pushViewController:self.peoplePicker animated:YES];
There is also a convenience method for presenting the people picker modally.
self.peoplePicker = [ZLPeoplePickerViewController presentPeoplePickerViewControllerForParentViewController:self];
Loading a large addressBook may take a long time. That's why ZLPeoplePickerViewController caches the addressBook in memory after it is first initialized. You can even further reduce the delay by calling this class method in advance (for instance, in viewDidLoad
).
+ (void)initializeAddressBook;
ZLPeoplePickerViewController uses the fieldMask property to filter contacts, graying out those that have missing information. Currently supported fields inlucde phones, emails, photo and addresses.
@property (nonatomic) ZLContactField filedMask;
The numberOfSelectedPeople property controls the multiple selection behavior. It indicates the maximum number of people the picker can select at the time.
@property (nonatomic) ZLNumSelection numberOfSelectedPeople;
A ZLPeoplePickerViewController can have an optional delegate to receive callback.
- (void)peoplePickerViewController:(ZLPeoplePickerViewController *)peoplePicker didSelectPerson:(NSNumber *)recordId {
// show an ABPersonViewController
[self showPersonViewController:[recordId intValue] onNavigationController:peoplePicker.navigationController];
}
- (void)peoplePickerViewController:(ZLPeoplePickerViewController *)peoplePicker didReturnWithSelectedPeople:(NSArray *)people {
// people will be empty if no person is selected
if (!people || people.count==0) {return;}
[self presentViewController: [self alertControllerWithTitle:@"Return with selected people:" Message:[[self firstNameForPeople:people] componentsJoinedByString:@", "]] animated:YES completion:nil];
}
- Support searching by phone number
ZLPeoplePickerViewController
uses APAddressBook
internally for accessing the addressbook. It requires APAddressBook.
- iOS 8 or higher.
- Automatic Reference Counting (ARC).
ZLPeoplePickerViewController is available under MIT license. See the LICENSE file for more info.