Hey, I was wondering if it is possible to make separate pickers that are dependent The reason for this being is that there is a lot of criteria and it would be way too crammed in one picker. So can I make say, 4 separate pickers, and make them dependent on one another? How would I approach something like this?
Hey, I was wondering if it is possible to make separate pickers that are dependent The reason for this being is that there is a lot of criteria and it would be way too crammed in one picker. So can I make say, 4 separate pickers, and make them dependent on one another? How would I approach something like this?
Thanks
You could, yes. If this is for an iPhone or iPod touch, though, you're going to have a tough time fitting multiple pickers on the screen. Pickers are HUGE. (I personally dislike how big they are, and wish Apple would offer a compact version.)
The logic to tie your different pickers together would belong in your view controller.
Set up all your pickers with the view controller as their delegate.
Then look for a –pickerView:didSelectRow:inComponent:
message. Since your view controller is juggling multiple pickers, you would have to look at the pickerView parameter to figure out which picker's value was changed. (Maybe set up tags on the pickers in IB so you can easily identify them?) If you want the act of changing one picker's setting to change the setting, or possible values, in your other picker(s), that logic would be triggered in your –pickerView:didSelectRow:inComponent: method. To simply change the active selection on another picker, you could use selectRow:inComponent:animated. However, you need to watch out for endless loops. If you have 3 pickers, and changing any of the 3 causes your code to change the selected item(s) in the other 2 pickers, I suspect that the system will call your –pickerView:didSelectRow:inComponent: method after your code changes the selected row.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
No, I mean like in the picture attached. I mean 4 separate, single pickers that are dependent on one another. For example, one single picker would be "Honda" then you close/hide that picker, then you touch somewhere else to make another picker come up where you can select "Civic".
@Duncan, I'm going to be showing/hiding the picker depending on what you wanted to select. And yes, i personally think the pickers are very huge. I will try what you suggested with the -pickerView:didSelectRow:inComponent: method. Thanks for the suggestion.
As a side note, are there any other ways of getting input from the user without actually inputting into a text box? A text box would give the user a lot of room for invalid input. I only remember using a picker when using my iPhone, is there a list that the user can choose from?
Last edited by Mystery; 05-27-2011 at 11:24 AM.
Reason: Duncan's Post
No, I mean like in the picture attached. I mean 4 separate, single pickers that are dependent on one another. For example, one single picker would be "Honda" then you close/hide that picker, then you touch somewhere else to make another picker come up where you can select "Civic".
Your picture didn't load.
So you want to have a series of view controllers in increasing detail:
The first picker would let you pick a type of transportation. You'd then click a button, and go to a new view controller that would display the sub-types for that type of transportation, and tap another button. You'd go to a third view controller that would show the specific model of car/truck/plane. Is that what you have in mind?
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
The first picker would let you pick a type of transportation. You'd then click a button, and go to a new view controller that would display the sub-types for that type of transportation, and tap another button. You'd go to a third view controller that would show the specific model of car/truck/plane. Is that what you have in mind?
Yes, that is exactly what I want the program to do. The pickers will be in increasing detail. The mode of transportation will always be a car. Once the user finishes selecting the car the data will be loaded to the application from a database according to the car the user selected.