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.

andygeers
  • 6,909
  • 9
  • 49
  • 63

2 Answers2

1

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

Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105
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];
}
Basbous
  • 3,927
  • 4
  • 34
  • 62
  • 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 '11 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 '11 at 12:47
  • Right... I'm not sure how that relates to the question, I'm afraid? – andygeers May 24 '11 at 09:25