在 ABPeoplePickerNavigationController 中设置提示

发布于 2024-09-19 01:53:15 字数 1013 浏览 2 评论 0原文

我无法获取此代码来设置提示:

// 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];

“添加提示”部分似乎没有设置提示。有什么想法吗?以下是输出的屏幕截图:

alt text

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅黛梨妆こ 2024-09-26 01:53:15

这个问题的关键信息(不太明显)是您需要在该行之后设置提示:

[self presentModalViewController:objPeoplePicker animated:YES];

因此,如果您这样做,它就会起作用:

[self presentModalViewController:objPeoplePicker animated:YES];
objPeoplePicker.navigationBar.topItem.prompt = @"Choose a contact to...";

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...";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文