views:

29

answers:

2

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?

+2  A: 

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?

deanWombourne
+1 for an alphabetized approach.
FreshCode
this could work. but a lot of taps (to open nesting levels) may annoy the user, is there a better approach? can I have something like ‘auto complete’ combo box i.e. where user types in a few letters of the choice and I show him a list of matching results?
ishaq
You could use a search bar at the top of the table I suppose - see my edit.
deanWombourne
guess I’ll use a a search bar, and when there are too many results to show (e.g. in case user has not typed anything or typed a search term too generic) I’ll just hide the table view and replace it with a label saying "Too many results, use the search bar to narrow down the choices"
ishaq
+1  A: 

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.

Sedate Alien
components are independent of each other’s selection. thanks for the answer though.
ishaq
@ishaq: Consider the `-reloadComponent:` method. If the user changes the selection for the most significant column (component), the options in the others can change. This functionality is used by a number of apps in the App Store as well as Apple's own apps (e.g. Calendar dates)
Sedate Alien
thanks @SedateAlien, that didn't cross my mind earlier, guess I was too preoccupied with auto-complete combo. This should work fairly well when titles of the choices can be distinctively broken down into components (say Region, Country, City, etc) and the number of components is about 3-4 (to fit on the device's screen). In my case, components would be a little more than that. But a good option for other case nonetheless.
ishaq