Try the search, it's linked to some great forums

Thursday, July 24, 2014

iOS Constraints and view layouts

iOS 5 has a nicely implemented auto layout feature called constraints. This posting provides a quickstart tutorial plus tips & hints. As usual Ray Wenderlich has a great intro tutorial that I used.

It seems the big secret is this button at the bottom of the storyboard. This button will allow Xcode to resolve most of your layout issues.  If you still have problems check out the video tutorial - Beginning Auto Layout by Ray Wenderlich

  The Auto Resolve Layout button displays the following selections;

  Use - Reset to Suggested Constraints in ......... , to allow Xcode to resolve the constraints.

Small blue lines indicate that this view is properly laid out.

Orange lines & text indicate conflicting contraints that need fixing

This screenshot shows both the good (blue) & bad (orange) layouts described above.

I fixed the Map cell layout by;
  1. selecting Clear all restraints in tableview cell
  2. manually dragging the label & image around for a basic layout
  3. selecting Reset to suggested restraints in .........
And you get this;


Easy - Peasey !