IOS 6 programming-auto layout Series

Source: Internet
Author: User

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 !!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.