0

I have an iPhone app that uses a ABPeoplePickerNavigationController to pick out a contact. First time you select a contact, the contact list obviously starts at the top, under the letter 'A'. However, say you selected a contact under 'M'; if you then later want to change which contact is selected, I want to initialise the contact list so that it's already scrolled to the 'M' section.

Here's the code I use to open the contact list:

ABPeoplePickerNavigationController *picker =
                    [[ABPeoplePickerNavigationController alloc] init];
                    picker.peoplePickerDelegate = self;                    
                    [self presentModalViewController:picker animated:YES];
                    [picker release];

I can't find any information in the reference guide on how to configure the scroll offset where the controller opens.

2 Answers 2

1

This functionality is unavailable in ABPeoplePickerNavigationController. However you can implement a custom UITableViewController which does that using the AddressBook framework.

0

Try to use the [ABAddressBook]

ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);

for( int i = 0 ; i < nPeople ; i++ )
{
    ABRecordRef person = CFArrayGetValueAtIndex(allPeople, i );
    NSString* name = [(NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty) autorelease];
}
3
  • I'm afraid I'm not entirely sure what this code is supposed to do - is this intended as an expansion of Deepak's answer?
    – andygeers
    May 23, 2011 at 10:06
  • no this code iterate over all all contact in iphone address book so you can get the data using Copy Value and property id.
    – Basbous
    May 23, 2011 at 12:47
  • Right... I'm not sure how that relates to the question, I'm afraid?
    – andygeers
    May 24, 2011 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.