Regarding the implementation of multi-component dependent uipickerview

I am having trouble understanding the concept of multi-component uipickerview. I really would just like to COLLECT this topic. I would like to make 4 pickerview components with components that are dependent on each other.

The first component is populated from the array from my db, and it looks fine. I have all the other information available in arrays, but I just hung over the dependent aspect of my choice. I believe the best way to make component 2 data depend on comp 1 is to link them somehow in the didSelectRow section. But I do not know the syntax.

I am working on this watch and feel that I am very close, but I just need help with a few problems. What is the syntax for connecting components so that they depend on each other? Something like that? (Which is terrible, I know, but I think this is the direction I need to get):

if(picker = pickerComponent1) //set number of rows for comp2 and also the content etc... 

Another problem is the definition of the numberOfRowsInComponent bit, because they are not in one method ...

If someone knows (or wants to give :) a tutorial on this, that would be so helpful! Or, if you are knowledgeable about this topic and would like to share some of what you know, that would be great too. I would very much like this seemingly simple task to be completed.

+3
source share
1 answer

It is pretty simple. In the pickerView:didSelectRow:inComponent: simply call [myPicker reloadComponent:] for all components following the one where the selection is selected. Then the collector will automatically query your data source (your view controller, presumably) for the number of rows and row values.

Then, in pickerView:numberOfRowsInComponent: and pickerView:titleForRow:forComponent: return the appropriate values โ€‹โ€‹(count and contents of the corresponding array) depending on the values โ€‹โ€‹of the selected rows of the parent components.

+3
source

Source: https://habr.com/ru/post/1499894/


All Articles