当用户按下“搜索”时收到通知在UISearchDisplayController的键盘上 [英] Getting notified when user presses "Search" on keyboard in UISearchDisplayController

查看:114
本文介绍了当用户按下“搜索”时收到通知在UISearchDisplayController的键盘上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 UISearchDisplayController 让用户搜索大学校园内的建筑物列表。有时,用户将确切地知道他们想要的建筑物,输入建筑物的编号,然后该建筑物将是UITableView中显示的唯一建筑物结果。此时,如果用户继续点击键盘上的搜索,则键盘会在屏幕上显示动画,然后用户必须在UITableView中的唯一项目上进行第二次点击以发送到地图上显示该建筑物位置的点。

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.

我的问题是,有没有办法在用户点击UISearchDisplayController内键盘上的搜索按钮时收到通知,以便我可以执行检查看看是否只有一个结果,如果是,请直接将用户带到该结果,而不是要求他们明确地进行第二次结果?我查看了 UISearchDisplayDelegate 提供的方法,但看不出任何相关的东西。

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:

UISearchDisplayController has a UISearchBar, you can set a delegate for search bar and implement -searchBarSearchButtonClicked:.

这篇关于当用户按下“搜索”时收到通知在UISearchDisplayController的键盘上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆