ABPeoplePickerNavigationController 编程式搜索?
我想调出用户的地址簿,并使用新的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果有人仍然想知道这一点,我通过操纵演示完成块中搜索栏的第一响应者状态找到了解决方案:
在拉出搜索结果之前有短暂的延迟,但这是我见过的最好方法发现在 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:
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
检查您是否声明了 ABPeoplePickerNavigationControllerDelegate 。
然后运行您的应用程序。我希望它能帮助你
check it whether you have declare ABPeoplePickerNavigationControllerDelegate or not.
and then run your app. I hope it will help you