1

I have a UIPickerView that contains values 0-100. When I scroll up, it ascends accordingly (0, 1, 2, etc.) (see attached image)

Is it possible to scroll down and have the numbers ascend that way?

Essentially I want to reverse scroll for the UIPickerView so in the provided image, the numbers would be reversed and as I scroll down the numbers will increase up to 100.

On viewDidLoad I tried

    [self.pickerView selectRow:100 inComponent:0 animated:YES];

However that just goes straight to 100 in the same manner.

picker view scrolling

Simon
  • 6,413
  • 6
  • 34
  • 57
  • if I understood correctly, why don't you reverse the part of the datasource. Instead of giving the string value for the row to "rowNumber %", give "100-rowNumber %"? – Larme Jan 04 '17 at 23:05
  • @Larme that was the original solution I had however, I did not mention the numbers are not always 0-100. I can have different arrays of numbers (i.e. 0, 25, 25, 50, 80, 100) and they would not be consecutive – Simon Jan 04 '17 at 23:12
  • Just reverse the array then: http://stackoverflow.com/questions/586370/how-can-i-reverse-a-nsarray-in-objective-c – Larme Jan 04 '17 at 23:13

1 Answers1

3

I suggest you reverse the order of the numbers in the data source and then set the initial selection to the last row. That combination gives you what you want.

I also recommend implementing (or finding a 3rd party implementation) a "circular" picker view. See the minute column of the picker view used on the Timer tab of the standard Clock app for an example of what I mean.

rmaddy
  • 314,917
  • 42
  • 532
  • 579