views:

197

answers:

2
+1  Q: 

Wrap PickerView?

Is there a way to wrap the fields in a picker view 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 picker would be able to scroll down forever, continuously repeating all the values.

Is this possible?

+1  A: 

See this: http://beardedpony.wordpress.com/2009/03/03/howd-you-get-that-cool-urban-spoon-type-animation/

It's sort of a hack, but read through it and it's how it's commonly accomplished.

marcc
thats a great way to do it...Hopefully the next release has pickerview.wrap = yes added to it.
Lumpy
I'm adding an answer for a better way to do it.
Mk12
A: 

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