john cs john cs - 1 year ago 91
iOS Question

UITableView not correctly aligning

I have a table that is during odd things with its alignment. IT is a UITableView on top of a view controller.

enter image description here

Why is there so much distance (the green line) between the navigation bar and the first cell? And why is there a small gap between the cell and the left side off the screen (red line)?
I can of course correct this with IB by dragging the TableView off screen but would rather fix this the 'right way' and understand why its doing this in the first place.

Tim Tim
Answer Source

Green line: do you have a table header view? If not, what is the content inset of the table view? Either of those can introduce some extra space atop the table view.

Red line: that's how table view separators are supposed to look by default. You can change that value by updating the separatorInset property.

A nitpick: you can't have a table view "on top of" a view controller. A view controller can manage a table view as its view (especially if it's a table view controller), or you can have a table view inside (as a subview of) another view managed by a view controller. View controllers, as non-view objects, never appear directly onscreen.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download