ABPeoplePickerNavigationController 编程式搜索?

发布于 2024-09-08 06:41:04 字数 612 浏览 2 评论 0原文

我想调出用户的地址簿,并使用新的 PeoplePicker 控制器对结果进行切片,以仅显示与特定术语匹配的结果。我看到 UIPeoplePickerNavigationController 中嵌入了一个搜索栏和搜索视图。看起来很标准的东西,我以前从未使用过它。

我如何以编程方式从刚刚以模态方式呈现 PeoplePicker 的 UIViewController 子类获取该信息?

这是我到目前为止所尝试的。不用说,这是行不通的。

ABPeoplePickerNavigationController *pick = [[ABPeoplePickerNavigationController alloc] init];
pick.searchDisplayController.searchBar.text = @"jim";
[self presentModalViewController:pick animated:YES];
[pick release];

编辑:更清楚地说,我想调出一个 ABPeoplePicker,但已经使用来自应用程序其他地方的搜索词进行“中间搜索”。如果用户想要取消该搜索并运行自己的搜索,那没问题,但我想首先使用我自己的术语预加载 searchviewcontroller。

I want to pull up the user's address book and use the new PeoplePicker controller to slice the results to show just those that match a certain term. I see that UIPeoplePickerNavigationController has a search bar and search view embedded in it. Looks like pretty standard stuff, I've just never used it before.

How would I get at that programmatically from a UIViewController subclass that has just presented the PeoplePicker modally?

Here's what I tried so far. Needless to say, it doesn't work.

ABPeoplePickerNavigationController *pick = [[ABPeoplePickerNavigationController alloc] init];
pick.searchDisplayController.searchBar.text = @"jim";
[self presentModalViewController:pick animated:YES];
[pick release];

EDIT: To be more clear, I want to bring up an ABPeoplePicker, but already "mid-search" with a search term that came from elsewhere in the app. If the user wants to cancel that search and run their own, that's fine, but I want to pre-load the searchviewcontroller with my own term first.

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

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

发布评论

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

评论(2

高速公鹿 2024-09-15 06:41:04

如果有人仍然想知道这一点,我通过操纵演示完成块中搜索栏的第一响应者状态找到了解决方案:

[self presentViewController:pick animated:YES completion:^{
    UISearchBar *bar = pick.visibleViewController.searchDisplayController.searchBar;
    [bar becomeFirstResponder];
    [bar setText:@"jim"];
    [bar resignFirstResponder];
}];

在拉出搜索结果之前有短暂的延迟,但这是我见过的最好方法发现在 ABPeoplePickerNavigationController 中完成编程搜索

In case anyone's still wondering about this, I've reached a solution by manipulating the first responder status of the searchBar in the presentation completion block:

[self presentViewController:pick animated:YES completion:^{
    UISearchBar *bar = pick.visibleViewController.searchDisplayController.searchBar;
    [bar becomeFirstResponder];
    [bar setText:@"jim"];
    [bar resignFirstResponder];
}];

There's a momentary delay before it pulls up the search results, but this is the best way I've found to accomplish programmatic searching in an ABPeoplePickerNavigationController

呆° 2024-09-15 06:41:04

检查您是否声明了 ABPeoplePickerNavigationControllerDelegate 。

然后运行您的应用程序。我希望它能帮助你

check it whether you have declare ABPeoplePickerNavigationControllerDelegate or not.

and then run your app. I hope it will help you

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