skip to Main Content

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

UI Design as below:
enter image description here

Heirarchy 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 ?

2

Answers


  1. The debug view hierarchy is correct. As you can see in the second photo, UITableView is at the same level as UIView (which is below Safe Area). Mapping with the first photo, they’re Table View and Top View. This table view has cells as its sub-views.

    Breaking down the view hierarchy: your HistorySearchView is a view controller, that is a child of UINavigationController, and this navigation controller is a tab item of UITabBarController.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search