Make radio buttons cells generic without knowing number. Adjusting tableview height with number of rows possible in AutoLayout?

Hi everyone,

Please recommend a proper methodology of doing this.
I’m trying to make a questions flow UI with various types of questions coming from backend json. I made a cell for each question type. But the problem is the radio buttons question I can toggle the state but, I dont know how many of them will be there 2,3,4 or 5 maybe. So i thought of making it generic by adding another tableview within cell and though of applying its logic by checking with IBOutlet if that tableview.

The problem is if the options increases the tableview allows them to scroll and I want all options to fit in one screen. So i thought of tableview.frame.size.height = rowHeight*numberOfRows. But didnt worked well. Im using self sizing cells also. Including this I also want a dynamically add row here by pressing an attachment button. So it possible for tableview like this with fitting all cells without scrolling?
One of the attachment cell is there gonna have a collectionview and AVFoundation methods.

The earlier approach I tried was to make a separate cell for everything. It was working but, I want some cells to insert at runtime. So i needed to update my data source count not some passing numbers. Else it will make index out of bounds error because i wont be able to know where to display that cell data. So you suggest.

Please help what is the way…or the best way.

You have prototype cells for your tableview right?

You can simply add an if statements or switch case, to check which cell you wish to add a radio button to.

I have one cell for one question only. Wouldn’t it be difficult to update the data source for insertion deletion if i make them as seperate rows? And then again how will you see the logic of radio buttons amon them?

OK I would need to see what you’re trying to do to get a clearer picture but you can still access cells by their index path row and components by tags.

what im thinking of is adding tableview within a cell. For number of radio button options for one question. I dont know how many of them it can by many. So where should i write that data source and delegate methods for that.