Question

If I have a UIPickerView with three components (dials). How does the picker handle two dials spinning simultaneously? For example, the user might flick the first dial, which spins freely and immediately slowly click to a selection on the second dial.

I'm doing the following in the picker. If one dial is spinning, I don't capture its value. I only capture values when the dials spin one at a time.

- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{

if(component == 0){
    dateEndCenturyText = (NSString *)[dateCentury objectAtIndex:row];
}
else if(component == 1){
    dateEndDecadeText = (NSString *)[dateYear objectAtIndex:row];

}
else if(component == 2){
    dateEndYearText = (NSString *)[dateYear objectAtIndex:row];
}

Is there a better way to ensure capture of values even if two dials are spinning?

Was it helpful?

Solution

The most robust solution to this may be to update all three values each time your event fires. You can retrieve the selected row for any component in the UIPickerView using the following method:

UIPickerView selectedRowInComponent:

Returns the index of the selected row in a given component

- (NSInteger)selectedRowInComponent:(NSInteger)component

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top