简体   繁体   English

当用户在UISearchDisplayController中按键盘上的“搜索”时收到通知

[英]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.

相关问题 UISearchDisplayController搜索栏会不会关闭键盘? - UISearchDisplayController search bar will not dismiss keyboard? 触摸文本区域时,UISearchDisplayController不显示键盘 - UISearchDisplayController not displaying keyboard when text area touched 使用UISearchDisplayController时显示搜索结果崩溃 - Displaying search results crashes when using UISearchDisplayController iOS 7 UISearchDisplayController无法在搜索数据时清除背景 - iOS 7 UISearchDisplayController not cleaning background when search data UIButton与键盘一起移动。 用户按下键时位置重置 - UIButton to move along with keyboard. The position resets when user presses a key “完成”按下时隐藏UITextView的虚拟键盘 - Hide Virtual Keyboard of UITextView when 'Done' Presses 自定义键盘:文本更新时得到通知 - Custom keyboard: get notified when text updates iPad键盘消失时如何获得通知? - How to get notified when the iPad keyboard disappears? 在通讯录更新时收到通知 - getting notified when addressbook updates 当UISearchDisplayController处于活动状态时,搜索栏上方的额外空间 - Extra space above search bar when UISearchDisplayController is active
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM