This might be a "hack," but it works. My case is slightly different. I'm using one UIPicker
, but can change what object it is manipulation.
My issue was that you could select one object, spin the picker, and while it is finishing its spin, select a different object. What ended up happening was the new object was getting the final value of that spin, rather than it being ignored.
What I did what when setting up the UIPicker
I'd give it a unique tag
based on the object that it was supposed to update.
- (void)updatePickerView:(UIPickerView*)pickerView
{
...
pickerView.tag = [self.myObject.position integerValue];
[pickerView selectRow:i inComponent:0 animated:NO];
}
Then when it finishes its spin, I check to make sure that tag lines up still.
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if (pickerView.tag == [self.myObject.position integerValue]) {
...
}
}
I'm not sure how it is functioning on Apple's side, but this was enough to make it work for me.
As a side note, and I'm not sure if this matters, but my UIPicker
is in a UITableViewCell
but since it is a reusable cell and because I was having the issues that I was, I assume the UIPicker is the same when it is moved from one position to another (as there is only one on screen at a time).
[picker selectRow:[picker selectedRowInComponent:i] inComponent:i animated:YES];
for each componenti
you have? – Theorize