Search code examples
iosobjective-cuipickerview

UIPickerView change/reverse scroll direction


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


Solution

  • 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.