我有一个应用程序,它异步搜索远程API并使用iOS的UISearchDisplayController显示UI。以编程方式使用UISearchDisplayController
对于已保存的搜索功能,我一直试图以编程方式使用UISearchDisplayController,以便启动搜索,并将用户界面设置为回到以前的位置。 (即,我想调出搜索栏,并设置搜索条件。)
searchTableViewController.searchDisplayController.searchBar.text = mySearchTerm;
//[...]
[searchTableViewController.searchDisplayController setActive:YES animated:YES];
[searchTableViewController performSearch];
我已经试过到目前为止的代码,上面doesn't似乎做的伎俩。虽然它能够正确显示搜索栏,设置搜索词并执行搜索,但系统似乎无法将其视为有效的搜索。如果我在结果视图中使用手指使键盘消失,则搜索词会自行重置,结果将消失。
帮助表示赞赏。谢谢!
http://stackoverflow.com/questions/8696260/creating-a-uisearchdisplaycontroller-programmatically – Hemang 2015-02-11 12:20:03