views:

74

answers:

1

I have the UIPicker setup with multiple components and a button below it. Depending on what the user has chosen with the UIPicker determines which new view will be loaded but I am having trouble determining how to extrapolate the information from the picker itself. Right now I have this method being called when the button is pressed:

- (IBAction) buttonPressed {
        if (component:1 == 1 && component:2 == 1) {
                //Load the view number 1.
        } else if (component:1 == 2 && component:2 == 1) {
                //Load the view number 2.
        } else {
                //Load the view number 3.
        }
}

I obviously know that my code is wrong but I hope it gets the point across. I have multiple components and I need to figure out how to use the information that the user is scrolling to on the picker to determine which view to move to. (I know how to load the views, I just commented those in the code to illuminate the problem areas better.)

How do I go about using the pickerViews to extrapolate the information IN the buttonPressed IBAction method?

A: 

To respond directly to picker manipulation, use the delegate's pickerView:didSelectRow:inComponent:.

To obtain the view corresponding to user selection, use viewForRow:forComponent:. From that view you can obtain information about what it displays (if it's a UILabel, inspect its text property).

Also, you can obtain this information directly from the data source, referring to the piece of information you would return in the delegate's pickerView:titleForRow:forComponent: or pickerView:viewForRow:forComponent:reusingView:, for the currently selected row and component.

luvieere
I don't quite understand what you are saying - what the difference between these are.
Rob
@Rob Your last edit was a bit clarifying, without it I thought you needed to get your information when your picker changed selection instead of when you touch the button. Now, I'm still confused what you mean by "to extrapolate the information". Would you mind giving an example of what kind of result you'd like to obtain? Give some mock data that's in the picker, and tell me what you'd like to get after extrapolating...
luvieere