I want to make a table like the one in the image, but the problem is that I want to do it with a dynamic table, since each section, for example the Adult section, can vary the number of cells depending on the passengers, just as the Children section can vary also, that's why I don't do it with a static type table, so the question is:
Is there a way to make a layout like the one in the picture using a pivot table? Or do I have to use a static table? But if I use a static table, how can I add the cells of each section to it dynamically?
If possible. You have to use a
UITableView
, and in the data source of the table you have to implement the methodsnumberOfSections(in:)
andtableView(_:numberOfRowsInSection:)
.In your case, the implementation would be this (obviously you have to see where to get the numbers from...):
If you want to do it with dynamic tables, you have to design them
TableViewCell
, and by code you must indicate to the data source of the table the number of rows that it must have for each section. You can do this if you have an array of the number of adult and child passengers or where you have that data, but you must indicate it to the function.