简体   繁体   中英

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. 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. 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.

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? I've looked at the methods provided by the UISearchDisplayDelegate , but can't see anything relevant.

UISearchDisplayController有一个UISearchBar ,你可以为搜索栏设置一个委托并实现-searchBarSearchButtonClicked: .

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {

}

This also works with the keyboard search button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM