views:

505

answers:

1

Is there a way to preset UISlider values to something such as:

100, 121, 10000, 40505, 100000, 460322, 1000024, 5005230, etc...

The numbers don't have a pattern. As the user moves the slider, I'd like to display the above numbers as corresponding to where the user is on the slider. The slider displays numbers in specific increments as floating point numbers. What is the best way to translate those values to the above...or should I use a different control?

A: 

There's nothing built-in, but it doesn't seem like that it's difficult to make something work. Just define a min of 0 and a max of X where X is the number of distinct values you need. Then when you need to get the value, just do a switch on (int)value

Ed Marty
One problem with that approach is that as I add new values, the enums will get messed up. Adding 122 for example, means it should get value 1 to correspond to the slider. However, values 0 and 1 are taken.
4thSpace
I'll load all of the values from a database and create a dictionary to hold them. As I loop through the database rows, I'll increment a counter, which will be the key use for index in the slider.
4thSpace