Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ashwinr87

macrumors member
Original poster
Mar 9, 2011
81
0
Hi,

In the UIPickerView I use in my application, I set the default value by using this -
Code:
[pickerView selectRow:0 inComponent:0 animated:NO];
and I use the
Code:
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
function to get the value of whatever number I pick from the UIPicker view.

The problem I am facing is that if I want to select the default item shown on the UIPickerView, untill I roll the wheel and come back to the default value, I am unable to select the default value. The `didSelectRow` function does not get called when I click on the default value.

Would someone be able to help me out with this problem?
 
You might need to look how you are presenting the picker view.

The picker doesn't have a cancel method of it's own it relies on the on the view presenting to handle that. It just reports any and all changes until the view gets closed off by it's superview (say a UIPopover). At that point you can take the selection to be the default or a new setting and change the data.

The assumption seems to be that if the user cancels the superview then they are either happy with the value or opened the wrong control and don't care.

You might need to make your controller a delegate of the presenting view as well as the picker so that it gets told about the cancelling of the view.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.