IOS 6 introduces the concept of auto layout in application user interface development. Use constraints to describe the positions, behaviors, and relationships of various views on the user interface.
In xcode 4.5, we can use interface builder, visual format language, or standard sdk api call (nslayoutconstraint class) and so on ).
Auto layout uses these constraints to calculate all views and set their positions and sizes. You no longer need to set the frame attribute of the view, that is, layout the view elements of the Interface Based on the constraints set for the view or element.
When you use xcode 4.5 to create an app, the auto layout function is enabled by default in all nib or storyboard files ). For specific settings, you can view previous articles.
Before iOS 6 introduced automatic layout, we used the springs and Struts mode to design a user interface that can be rotated and adjusted. There are three main methods to summarize and review:
1. Automatic rotation and automatic resizing
By setting the autosizing attribute of various views in the size Inspector panel, you do not need to writeCodeBut this is only applicable to simple UI applications.
2. Adjust the View frame (frame attribute)
Each UI element is defined by a rectangle area on the screen. This rectangle area is the frame attribute of the UI element. You can use the C function cgrectmake (X, Y, width, height) to redefine the frame attribute of a view.
If there are many UI elements, You need to track the size and position of each UI element, and the code design is troublesome.
3. Redesign different views-horizontal and vertical views
Define two views horizontally and vertically in each scenario. Each view must have an independent output port. Although two views are associated with the viewcontroller of the same view, the output ports cannot be shared, and the number of UI elements to be interacted in the View Controller is doubled. Of course, the advantage is that different views are completely independent to avoid mutual influence.
The above three methods have some shortcomings in the development process. The auto layout introduced by iOS 6 aims to improve this deficiency. I personally think it can also adapt to the increasing numbers of iPad and iPhone devices of different sizes.
IOS 6 programming-auto LayoutArticle:
IOS 6 programming (15)-creating an auto layout simple application
IOS 6 programming (16)-interface builder Automatic Layout Function
IOS 6 programming (17)-in-depth demonstration of Automatic Layout
Not yet resumed !!