I need to have a search bar control in my iPhone applicatio开发者_如何学JAVAn, but I'd like to have it so that you can search using only a single letter. For example, I'd like to enter a letter into the search box and have a list of items starting with that letter appear.
How would I implement something like this?
Try using the searchBar:textDidChange:
method on UISearchBarDelegate.
The drop down list is mostly a table view in iOS. You have two options – Use a search bar with a table view and respond to its delegate method. The delegate will message you on text entry. You will need to process it and feed the table view with proper data. This is pretty basic stuff. It things seem a bit complex, you can look at UISearchDisplayController
. This is a convenience tool to achieving the same thing mentioned above.
Now, the issue is to figure out a way to process it within time. For a smaller data set, you could probably go for on the spot filtering but with larger data sets, you need to have some sort of indexing. Otherwise you might end up with bad user experience.
Take a look at tutorials to feel comfortable.
精彩评论