在 ABPeoplePickerNavigationController 中设置提示
我无法获取此代码来设置提示:
// 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];
“添加提示”部分似乎没有设置提示。有什么想法吗?以下是输出的屏幕截图:
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:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题的关键信息(不太明显)是您需要在该行之后设置提示:
因此,如果您这样做,它就会起作用:
The key piece of information to this question, and not quite obvious, is that you need to set the prompt after the line:
So, if you do it like this, it works: