tags:

views:

627

answers:

2

I have a UIPickerView with multiple components. Some values are grayed out, and my pickerView:didSelectRow:inComponent honors this by shifting the picker component in question to the nearest valid value, much as UIDatePicker moves from "30" to "28" when you select "February". Then it calls a delegate method to announce the adjusted value.

When my adjuster method calls my UIPickerView's selectRow:inComponent:animated:YES, the value on screen is correct, but the values from selectedRowInComponent: are stale (from before the adjustment for gray values). However, if I call selectRow:inComponent:animated:NO, the returned values are correct, but the lack of animation is jarring.

I've tried wrapping the adjustment in a beginAnimations:/commitAnimations block and catching the values in UIView's +animationDidStopSelector, but I still get stale values. Has anyone run into this before?

A: 

Hi Eric,

I had the same problem and it is easy to duplicate.

[picker selectRow:newValue inComponent:i+offset animated:YES];

retValue = [picker selectedRowInComponent:i+offset];

If you have YES to animated it, then retValue is 0 on mind (you call it stale). Changing to NO, retValue will be the same as newValue.

I wanted to animate and return newValue. Does anyone know how to solve this?

munchine
A: 

Have the same problem, anybody knows how to solve this?

Daniel Malmquist