Category Archives: Layout

iOS8 Self Sizing UITableView Cells

The UITableView is a class we all have used at least once in our apps.

Sometimes we need a UITableView with cells all equal in height, but sometimes we need dynamic height cells, each one having a different height, typically dependent on its own content.

The old way

Before iOS8, this was not trivial since the system needed to know in advance the overall height of the table in order to set the content size of the scrolling area (UITableView inherits from UIScrollView).

Continue reading iOS8 Self Sizing UITableView Cells

iOS8 Layout Margins

iOS8 SDK introduces a new concept: the “layout margins”. A new property has been added to the UIView class:

These 4 values (the UIEdgeInsets fields) represent the margins of the view. Its subviews can now be positioned relative to these  margins.

For example, this is the result of an inside view whose leading space to the superview is 0 (relative to margin):

Schermata 2014-09-15 alle 13.09.59

Continue reading iOS8 Layout Margins