[英]Getting notified when user presses “Search” on keyboard in UISearchDisplayController
I am using a UISearchDisplayController to let the user search through a list of buildings on a university campus. 我正在使用UISearchDisplayController让用户搜索大学校园内的建筑物列表。 Sometimes, the user will know exactly what building they want, enter the building's number, and that building will then be the only building result showing in the UITableView. 有时,用户将确切地知道他们想要的建筑物,输入建筑物的编号,然后该建筑物将成为UITableView中显示的唯一建筑物结果。 At the moment, if the user proceeds to hit "Search" on the keyboard, the keyboard animates off the screen and the user then has to make a second tap on the sole item in the UITableView to be sent to a point on a map showing the location of that building. 此时,如果用户继续点击键盘上的“搜索”,则键盘会在屏幕上显示动画,然后用户必须再次点击UITableView中的唯一项目以发送到地图上的某个点那栋楼的位置。
My question is, is there a way to be notified when the user hits the "Search" button on the keyboard inside a UISearchDisplayController, so that I can perform a check to see if there's only one result, and if so, take the user straight to that result, rather than requiring them to explicitly make the second tap? 我的问题是,当用户点击UISearchDisplayController内键盘上的“搜索”按钮时,有没有办法得到通知,这样我就可以检查是否只有一个结果,如果是,请直接让用户结果,而不是要求他们明确地进行第二次点击? I've looked at the methods provided by the UISearchDisplayDelegate , but can't see anything relevant. 我查看了UISearchDisplayDelegate提供的方法,但看不到任何相关内容。
UISearchDisplayController
有一个UISearchBar
,你可以为搜索栏设置一个委托并实现-searchBarSearchButtonClicked:
.
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
}
This also works with the keyboard search button. 这也适用于键盘搜索按钮。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.