开发者

How do I implement a single-letter-based search using the search bar?

开发者 https://www.devze.com 2023-03-08 00:46 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消