How to set ABPeoplePickerNavigationController tooltip?

This is the code I use to call the people picker, but the text of the tooltip does not change:

ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
picker.displayedProperties = [NSArray arrayWithObjects: [NSNumber numberWithInt:kABPersonEmailProperty], nil];  

picker.navigationItem.prompt = @"Choose a contact to...";

[self presentModalViewController:picker animated:YES];
+3
source share
4 answers

You can change the title with:

picker.navigationBar.topItem.title = @"iPhone Contacts";

And you can change the prompt with:

picker.navigationBar.topItem.prompt = @"iPhone Contacts";
+1
source

Other answers lack a key piece of information and are not entirely obvious. You need to set the line after :

[self presentModalViewController:picker animated:YES];

So, if you do this, this works:

[self presentModalViewController:picker animated:YES];
picker.navigationBar.topItem.prompt = @"Choose a contact to...";
+6
source

. , .

picker.navigationItem.prompt = @"Choose a contact to...";

picker.navigationBar.topItem.prompt = @"Choose a contact to...";
+1

If you subclass ABPeoplePickerNavigationController, you need to set this as soon as the controller is clicked. This is essentially what Johan suggested, but from within the class.

The ABPeoplePickerNavigationController implements the following delegate method:

-(void)navigationController:(UINavigationController *)navigationController 
     willShowViewController:(UIViewController *)viewController 
                   animated:(BOOL)animated
{
    [[[self navigationBar] topItem] setPrompt:@"test"];
}
0
source

Source: https://habr.com/ru/post/1736800/


All Articles