views:

31

answers:

1

I'm having trouble getting this code to set the prompt:

// Create a PeoplePicker
ABPeoplePickerNavigationController *objPeoplePicker = [[ABPeoplePickerNavigationController alloc] init];
[objPeoplePicker setPeoplePickerDelegate:self];

// Customize colors
objPeoplePicker.topViewController.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.294 green:0.278 blue:0.247 alpha:1.0];
objPeoplePicker.topViewController.searchDisplayController.searchBar.tintColor = [UIColor colorWithRed:0.294 green:0.278 blue:0.247 alpha:1.0];

// Only display phone numbers
NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty], nil];
objPeoplePicker.displayedProperties = displayedItems;

// Add a prompt
objPeoplePicker.navigationBar.topItem.prompt = @"Choose a contact to...";

// Show the picker
[self presentModalViewController:objPeoplePicker animated:YES];

The "Add a Prompt" section doesn't seem to be setting the prompt. Any ideas? Here's a screenshot of the output:

alt text

A: 

The key piece of information to this question, and not quite obvious, is that you need to set the prompt after the line:

[self presentModalViewController:objPeoplePicker animated:YES];

So, if you do it like this, it works:

[self presentModalViewController:objPeoplePicker animated:YES];
objPeoplePicker.navigationBar.topItem.prompt = @"Choose a contact to...";
Johan Kool
Worked flawlessly! Thanks!
Jesse Bunch