When working with Interface Builder (no matter what kind of document, Storyboard, View Controller, View, etc.), there is a checkbox in the File Inspector
to Use Auto Layout
.
Checking the source of an empty document, we see that it translated to a flag called useAutolayout
:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
</objects>
</document>
What is the equivalent when working without Interface Builder and purely building a UI in code?
Note: Please note that I posted a related question here. However, this new question targets the specifics of the technical details of the useAutolayout
property whereas the former looks at the problem from a higher level which is why I found it appropriate to post a new question instead of updating the other.