What do I do if I need to allow the user to select an option from a really long list? If I use the picker view then the user would have to take a long time to spin to the desired option. Is there a way to allow the user to type text that would take them to the desired option that begins with the text they type?
better picker view
You can select a row programmatically in the pickerView
h ttps://stackoverflow.com/questions/4894705/can-i-programmatically-scroll-to-a-desired-row-in-uipickerview
Then you need (I have not looked in detail how to do it) to:
- get the key typing
- find which row in dataSource to select
- select the row programmatically
Hope that helps.
You can also create sections in picker:
h ttps://stackoverflow.com/questions/41387902/how-do-i-add-section-titles-in-a-uipickerview
What is "key typing"?
I mean intercept the keyDown events.
with override func keyDown(event: NSEvent)
You could test if picker is first responder, then handle as you need ; if not, pass the event.
However, asking user to type will open the keyboard, which may overlap the picker. Take care of UI design.
Anotherway would be to have a series of indexex (letters 2 by 2 for instance) : typing on an index would set the picker to the initial ; then user would end scrolling manuallynwith much shorter movement.
Did you find the solution ?