views:

409

answers:

3

I want to create a UIPickerView with the easiest way possible, because all of what I know Is not enough to help me

Ok what I ment is that I am trying to get a UISegmented that will end up creating a UIPickerView but I want to create a UIPickerView that shows up when I select one of the segments in the segmented control animated, and also the pickerview is supposed to use an array that has colors like red green blue

A: 

Read this, or watch this video. They go through creating a simple UIPicker step-by-step.

Ben S
A: 

Ok what I ment is that I am trying to get a UISegmented that will end up creating a UIPickerView but I want to create a UIPickerView that shows up when I select one of the segments in the segmented control animated, and also the pickerview is supposed to use an array that has colors like red green blue

Jaba
You should add this clarification to the parent post. You should also break the question down into smaller chucks i.e. How do I create a UIPickerView in view loaded by a segmented control? How do I animate a UIPickerView? How do I use an array of colors to populate a picker view? etc. You question as it stands covers a lot of ground. People would have to write your app for you to answer such a general question.
TechZen
A: 

For your UISegmentedControl, you'll need to register target-action methods. For example:

[segmentedControl addTarget:self
                 action:@selector(updatePicker:)
       forControlEvents:UIControlEventValueChanged];

Inside of updatePicker, set a variable that corresponds to whatever you want to show in your picker. Then, to your picker instance (you should only have one instance of this class), send the reloadAllComponents message. This will update the picker by querying the delegate for new data. In your delegate (which can probably all be the same class), you'll want to check the value of the variable you set in updatePicker to determine what data to return to the picker.

bpapa