Build an App Like Lego — Tutorial 11

Tom Brodhurst-Hill
Build an App Like Lego
7 min readFeb 4, 2019

--

Dynamic Sizing

1. Introduction

In Tutorial 10 we completed the attributes in our News cell. When we viewed the cells at runtime, the detail text and image were both truncated and weren’t showing their full content.

In this Tutorial 11 we will employ a few mechanisms to allow the content to grow and for the cells to automatically set their size.

2. Default Cell Height

When we created the NewsTableViewCell layout, we included a constraint to the top and bottom margins. This allows the cell to determine the height that it needs to show all of its content (i.e. its “intrinsic content size”). If the text or images grow, the cell knows that it needs more height.

By default, a table view will automatically determine the height of its cells to fit their contents.

👉 Select both of the cells in the News scene. One way to do this is to click on one cell, then hold down shift while clicking on the other. Select the Size Inspector (the ruler icon).

--

--

Tom Brodhurst-Hill
Build an App Like Lego

iOS developer and architect for BareFeetWare. Builds apps for enterprise and startups. Runs workshops on building apps like Lego.