Reputation: 65
I'm trying to create quiz answers, but because of the
var cell = (CreateMessageNewAnswerCell)TableView.DequeueReusableCell(CreateMessageNewanswerCell.Key);
I'm receiving the same box sizes from previous times. I know that the Dequeue method reuses the cells and therefore the size stays the one before, I've trying to reset the sizes but it gets itself to an unsolvable problem where the cells change places in their sizes(because of the reuse).
And therefore my question is, how do I create cells without reusing them. I have tried the following code but it didn't work
var cell = new CreateMessageNewAnswerCell(UITableViewCellStyle.Default, CreateMessageNewAnswerCell.Key);
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
cell.SetModel(createMessageSession.AddAnswersModel, indexPath.Row - 1);
Upvotes: 0
Views: 338
Reputation: 1303
If you are displaying similar cells in your UITableView then I do not recommned not using cell reuse as it would negatively impact your scrolling performance and increase memory pressure.
To Handle cells of different size in one UITableView, you could use AutoLayout and set your cells height to Automatic Dimensions.
TableView.EstimatedRowHeight = 200;
TableView.RowHeight = UITableView.AutomaticDimension;
This will ensure your cells height fit their content dynamically. For more info checkout this post.
If you still do not want to use cell reuse then don't use DequeueReusableCell instead just return a new instance of your cells in the GetCell method.
Upvotes: 2