开发者

how to implement picker for a large amount of values

I have about 20,000 records (coming from an SQLite db) that I need to present to the user for possible choices, so conventional picker control is out of question.

Another possibility could be an indexed UITableView where user could check the desired value, however keeping all the 20K records in the memory doesn’t 开发者_开发知识库seem like a good idea.

how should I go about implementing UI for it? EDIT: is it possible to do something like auto-complete combo-box?


I'd look at some sort of nested UI i.e. a UITableView that has just A, B, C etc to start with and when the user presses on a row show another table view with all the results starting with A.

There would need to be a query that got the number of results that started with A, B, C etc so you only showed letters in the first table that actually has results but then each query in the second table would be very simple - all results starting with 'A' etc.

You'd never have to load all 20,000 results into memory at the same time :)

However, you should probably make sure that you have an index on the field that you're querying, otherwise your queries are all going to be rather slow :(


The other solution is to use a search box at the top of a table view - the user types in letters and each time the list is reduced to only results starting with that letter. That's a pretty simple query to implement :)

However, you would then still have the problem of what to do if the user hasnt typed anything in - do you show a message asking them to type or do you show all 20,000 results in an enormous list?


Are you aware of UIPickerView's "components"? 20,000 choices might be pushing it, but it is certainly one way (that is familiar to users) to narrow down choices by an order of magnitude with each spin.

If you find yourself constrained in one dimension, you could implement master-slave picker views.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜