This is what happens when you click
As shown in the image above, every time I select Cell, the display is reversed.
This is UITableView's DidSelectRowAtIndexPath
I would like to add cellForRowAtIndexPath just in case.
I'm so into it that I can't move forward easily.
I look forward to hearing from you.
I think it was coded by referring to the sample in .
If you compare it with the sample, you'll find out right away.
cellForRowAtIndexPathThe first two lines of your coding
is not in the sample.
I think this part you added is the cause of the defect.
dequeReusableCellWithIdentifier is a method to reuse previously used cells.
Cells used in different table rows may be reused.
Your coding returns the acquired cells as a return of the method without doing anything, so
I returned the cell that I used to display Option 3 as a cell for displaying Option 1.
If you update the table display, the display order will be incorrect.
After retrieving the previously used cell in
The contents of the cell must be updated to display the lines specified in indexPath.
The processing was originally included in the reference sample coding.
In other words, the two lines you added are unnecessary, and if you remove them,
The default action for the case statement should work to ensure proper display.
© 2022 OneMinuteCode. All rights reserved.