UITableView hierarchy is not in a single line

73 views Asked by At

I have a simple table view with cells. When I run the app in simulator and checking the hierarchy it is not aligned in single line, instead it is looking as nested.

UI Design as below: enter image description here

Hierarchy looks as below: enter image description here

It looks fine in other view controller, please check below image: enter image description here

My concern is table view cells are not aligned in single line. But for other table views cells are on the same line, check 3rd image.

Can someone please help how can i solve this problem ?

1

There are 1 answers

0
DonMag On

A UITableView does a lot of work "behind the scenes."

One big task is managing efficient display of its cells - remember, cells are reused.

As you begin using the table view, cells are added. As you scroll, some more cells will be added... but then they start to be reused.

Note also that the scroll indicator view is part of the hierarchy!

So, depending on cell heights (and, I'm sure, many other factors) the table view may add 3 cells, then add the scroll indicator view, then add 2 more cells - giving you a "staggered" hierarchy.

As you continue to scroll, the table may (almost certainly will) rearrange the order of the cells. So each time you use Debug View Hierarchy the cells "level" in the hierarchy can (will) change.

This is completely normal, and, unless we're doing something with the cells that we probably should not be doing, will have no adverse effect.