A more flexibel and customisable implementation of ABPeoplePickerNavigationController
Objective-C
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
GKClasses
GKPeoplePickerViewController.xcodeproj
GKPeoplePickerViewController
.gitignore
README.md
license

README.md

GKPeoplePickerNavigationController

Ever wanted to customize Apple's ABPeoplePickerNavigationController in some way? You probably figured out that it's quite impossible to do it. I ran into the same issue that's why I wrote a dead simple drop in replacement for it.

It supports pre selecting a contact and can pre fill the search bar.

It's tested under iOS 5.0 and iOS 6.0 and supports ARC.

How to use it

  • just drag and drop the files under "GKClasses" into your project.
  • add the AddressBook.framework and AddressBookUI.framework to your project
  • look at the sample code below.
  • this project contains a sample project as well, just have a look at the implementation of ViewController.m
  • have fun and follow @gekitz.

Sample Code

How to preselect a contact:

ABRecordRef person = <# retrieve person from somewhere #>

[GKPeoplePickerNavigationController requestAccessToAddressBookWithCompletion:^(bool granted, CFErrorRef error) {
    if (granted) {
        
        GKPeoplePickerNavigationController *ctr = [[GKPeoplePickerNavigationController alloc] init];
        ctr.preselectedPerson = person;
        [self presentViewController:ctr animated:YES completion:nil];
        
    }
}];

This results in: preselect person image

How to prefill the UISearchBar:

    [GKPeoplePickerNavigationController requestAccessToAddressBookWithCompletion:^(bool granted, CFErrorRef error) {
    if (granted) {
        
        GKPeoplePickerNavigationController *ctr = [[GKPeoplePickerNavigationController alloc] init];
        ctr.prefilledSearchTerm = @"Georg";
        [self presentViewController:ctr animated:YES completion:nil];

    }
}];

This results in: prefilled search image

License

Under MIT.