1

Is there a way to wrap the fields in a UIPickerView so it more closely resembles what it is simulating. Once I get to the last value I want to see the first value below it. This UIPickerView would be able to scroll down forever, continuously repeating all the values.

Is this possible?

Code cracker
  • 3,105
  • 6
  • 37
  • 67
Lumpy
  • 3,632
  • 4
  • 34
  • 58

1 Answers1

0

First add this function:

#define row_to_array_index(row) row%[YourArrayOfRowValues count]

assuming you an NSArray called YourArrayOfRowValues that holds the text for each row.

Then in your - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component method, return a big number (like 10000), and in your - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component method, return (assuming only 1 component) [[self YourArrayOfRowValues objectAtIndex:row_to_array_index(row)];

There will be no performance or memory hit. No user will ever try to go down 10 000 rows, trust me. And when the window is reloaded, select the same data closest to the middle.

mk12
  • 25,873
  • 32
  • 98
  • 137