I am trying to make a expandable table view (static cells). A container view is placed inside a cell below the "Lists of options" cell, as shown below:

The problem comes with the animation when expanding / collapsing. The topmost cell of each section will disappear briefly(hidden?), then reappear after the animation ends. I have later experimented and the results are as followed:

This will not happen when using

tableView.reloadData()

.

This will happen when using

tableView.beginUpdates() / endUpdates()

pairs.

Hence I have come to the conclusion that this has sth to do with the animation. Below is my code and pictures for further explanation for said issue.

After searching for a few days, I have found the cause to this behavior.

I have, for some reason, set the cells layer.zposition below default zero. This will cause the cell to be seen "below" it's background view (hence disappeared) during the animation even though it's a subview of it.