iphone UIpicker with 2 components scrolling both at the same time

631 views Asked by At

I would like to create a UIPicker with 2 components, there will be numbers in both of them. The number selected in the first, left picker must be lower (or equal) than the number selected in the second one. I want these two components to be synchronized, if I scroll down for example the fisrt one, and the selected number in the fisrt coloumn equals to the number selected in the second coloumn, then I want the second coloumn to be scrolled down automatically when I continue scrolling down in the first one. Im new to iphone development, could you help me with a code? Thank you very much!

Daniel

1

There are 1 answers

0
viggio24 On BEST ANSWER

I don't think this instant synchronization is possible. You can keep two components in sync by appropriately responding to the following UIPickerViewDelegate method:

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

the only issue is that this function is called a few milliseconds after the wheel finish its movement, so you can sync the wheels only after they did stop their movement. So you may have delayed synchronization (just look at the UIDatePicker behaviour when you try to insert incorrect dates, such as 31 June), but not instant one (unless you build a completely custom view).