Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPickerView problem about selecting first value

I succesfully implemented a UIPickerView. However, I have a problem in selecting values.

According to the standard way, I have implemented the method

- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { 
 // method implementation...
}

The problem is when I try to select the very first value. By default the first item is selected, so if I want the method to be called for the first row I have to scroll down, select a value, then scroll up to the first one again. What am I missing here ? Is there another way of doing this ? Also, is it possible to get selected value without moving the picker ? Because I have a view containing components as UITextField and UIPickerView and I am in need of scanning the whole view for getting components values.

thanks Leonardo

like image 440
Leonardo Avatar asked Feb 16 '26 04:02

Leonardo


1 Answers

You could use the selectedRowInComponent: method to get the selection without waiting for a use action.

Or if you want a user action, you could add a blank (or use-current, or no-selection, etc.) row somewhere and use the selectRow:inComponent:animated: method to select that.

like image 91
hotpaw2 Avatar answered Feb 19 '26 03:02

hotpaw2