Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 721
john cs Avatar asked Dec 07 '25 03:12

john cs


2 Answers

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.

like image 58
Tim Avatar answered Dec 08 '25 18:12

Tim


You can use autosizing if you are using xib or storyboard for designing. In Interface Builder on tap "Size inspector" you can choose autoresize mask you want. Also in little square screen it will animation with using autoresize so you can see what option did you set. http://www.techotopia.com/index.php/IOS_4_iPhone_Rotation,_View_Resizing_and_Layout_Handling

like image 39
Bhushan Vaidya Avatar answered Dec 08 '25 18:12

Bhushan Vaidya