4 ms·
The one place where I've found autolayout makes things much easier is dealing with variable height table cells. Manually measuring the heights of cells is a lot
by nodamage 9y ago
The one place where I've found autolayout makes things much easier is dealing with variable height table cells. Manually measuring the heights of cells is a lot more work compared to using self-sizing cells and having autolayout do it for you. Especially if you want to support Dynamic Type which means that every table cell containing text potentially has a variable height.
On the other hand, there are situations where if your views are highly dynamic then the complexity of autolayout starts to negate its benefits. Any time you need to save references to a bunch of constraints so you can adjust their constants or toggle them on/off later. Or if you have one set of constraints to start but need to replace them with other constraints at runtime as your data changes. Or if you have a lot of subviews to layout and you need to start coordinating content hugging/compression resistance/layout priorities between them. (This is the worst cause it starts to feel like you are adjusting arbitrary magic numbers to make your layout behave the way you want.) At some point you cross a threshold where your autolayout code gets absurdly complicated and you might as well have done it all manually.
Ultimately I've found it best to treat autolayout like any other tool in the box: use it when it makes things easier, but don't hesitate to rip it out and do things manually when the situation arises.
- hyberbole_1234 9y agoI recommend using Cartography for this