26
votes

What is Auto Layout - what does it do, and is it an iOS 5 feature?

Since the new iPhone 5 has a bigger screen, all the options on how to optimize your applications for it come down to Auto Layout.

Can you point me to some article about Auto Layout, and how I can adapt it with my project?

7
As mentioned below, it is an iOS 6 feature and similar to auto-layout in Cocoa, but simpler to use. - lostInTransit
You may want to look at UIViews autoresizesSubviews and autoresizingMask. This can be used prior IOS6 and is a nice way to autoresize your view for iPhone, iPad and iPhone 5. - Sascha Manuel Hameister
this gives better understandings of how auto layout works in iOS slicode.com/… - Shankar BS

7 Answers

28
votes

I recommend watching the WWDC 2012 session Introduction to Auto Layout for iOS and OS X.

Auto Layout is a new way to define dynamic GUIs. Before, we had autoresizing masks, that described how a subview will resize or move when its superview is resized. With Auto Layout you can do the same and also a lot more complicated GUIs quite easily.

4
votes

https://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AutolayoutPG/Articles/Introduction.html

"If Auto Layout in iOS 6 turns out to be anything like Cocoa Auto Layout in Mac OSX 10.7, the Cocoa Auto Layout Guide, a publicly available document, may give you an idea of how it would work in Cocoa Touch.

The underlying engine used by Cocoa Touch is Cassowary, and it's also used in other toolkits, such as enaml. I recently wrote a brief overview of Cassowary, with a comparison between Cocoa Touch and enaml wherein I port a Cocoa Auto Layout example to Python and enaml."

From: https://stackoverflow.com/a/11129597/1648976

And the WWDC Session: https://developer.apple.com/videos/wwdc/2012/?id=202

3
votes

iOS 6 is still under NDA. Hold out for a few more days. It is an iOS 6> feature. In case you have a developer account, you must be already able to learn about Auto Layout from the documentation or from the WWDC 2012 session videos.

0
votes

"Autolayout" is used to adapt layout to different screen size,orientation and localisation.

In Autolayout we don't give input based on "x" and "y" coordinate (old style). Instead we define the layout using mathematical relationship between the elements in our view. We can define this relationship using constraints or individual elements or constraint between a set of elements. Once we redefine the layout using this relationship .Our app can adapt to different layout based not only on device size like 5 inch or 5.5 inch in iPhone, but orientation and localisation as well.

For further understanding you can visit:http://www.raywenderlich.com/83129/beginning-auto-layout-tutorial-swift-part-1

0
votes

What is Auto Layout?

Auto Layout is a constraint-based layout system. It allows developers to create an adaptive interface that responds appropriately to changes in screen size and device orientation. Without using Auto Layout, it would be very hard for you to build an app that supports all screen sizes.

enter image description here

Why Auto Layout?

Auto Layout is a way that lets developers create user interface by defining relationships between elements. It provides a flexible and powerful system that describes how views and the UI controls relate to each other. By using Auto Layout, you can get an incredible control over layout, with a wide range of customization, and yield the perfect interface.

Auto Layout is compatible with many of Apple’s most exciting application programming interfaces (APIs), including animations, motion effects, and sprites.

enter image description here

Reference: https://www.appcoda.com/introduction-auto-layout/

0
votes

UIView Autolayout is a very interesting concept in iOS App development. Autolayout takes care of responsive design. iPhone comes with different screen sizes every time. With the help of Autolayouts, you do not have to create your App design each time. Autolayout takes care of responsive design.

This article on "Introduction to Autolayouts" will give you enough understanding about it.