开发者

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 didSelectRo开发者_开发知识库w:(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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜