IOS7.0 Xcode5 AutoLayout memo

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Xcode5 Xib AutoLayout:

List 1:

(two view can be set)

The left alignment, 

Right align, 

Align top, 

Align bottom, 

The X axis is aligned with the center, 

The Y axis is aligned with the center, 

The bottom line is aligned text, 


(single select an view can be set)

For aligned X axis center of the parent view, 

For aligned Y axis center of the parent view, 


(box)

Add constraint no operation,

Rearrange the constraints involved in adding constraints view,

To put all this in the container by adding view constraints


The OK button, select the above project and click add constraint


The cross is "with the nearest neighbor constraint", fill in the numbers, click the dotted line into line is to add this constraint.

Here the "neighbors" is a view that contains child parent view as a loaded a pile of building blocks to the box box, frame and other building blocks as "neighbors"


(width and height data defined constraints)

The width specification,

Highly specified,


(definition of high width constraints between multiple view)

The same width,

The same height,


(list, alignment constraints between multiple view, equivalent to the previous menu content)


(list, frame update mode, equivalent to the previous menu)

(add click OK button, set constraints)


(half of the currently selected menu operation object is view, the lower part of the operation of the object is selected in the view view)

Refresh the frame (using all constraints currently set),

Refresh constraint (update constraints according to the current constraints and frame, constant value),

Add the missing constraints (automatically add the system thinks you should add but forget to add constraints, often produce conflict test)

Reset the constraint system recommended (cleaning system that repeat / conflicting constraints, often have problems in testing)

Clean all the constraints (delete all constraints that object bound)


(refresh what view at the time, adding a constraint)

The view and the parent view

View


The problem:


Conflict between constraints and constraints, both the Xib and the Xib, Xib and code, code and code.

Conflict is generally only in certain circumstances, such as vertical screen no problem but cross screen appear conflict, may also drag Xib wrong up like conflict.

The system will automatically resolve conflicts, often rely on the right level, but generally use a constraint cannot determine what should be in the right order, so it is difficult to set the right level right to deal with the conflict.

Conflict, the same case different processing may be in the system of automatic solution, leading to some cannot always reproduce the problem.

Constraint conflict, debug adjustable error occurs log, according to the log lookup conflict resolution.

A constraint violation, not on ios6 crash, ios7 in sporadic crash.

 

The Xib and code selection:


AutoLayout now is not "use" of the problem, But "how" questions, The underlying framework seems to have been completely removed autoresizemask, It automatically converts autoresizemask to auto layout is to say, In this case you can use the original autoresizemask, But the system will they brought when the AutoLayout., In the process of using the automatic conversion of constraint will be facing the same conflicts, The conflict problem more bizarre and bad treatment

Now I often encounter is the, For example, a control, The use of AutoLayout between it and its parent view is specified by the code, I'm sure constraint form, But in the implementation of it in order to facilitate the use of Xib to deal with their own view, The Xib drag and drop constraint due to relatively complex and I have not yet clear, There will be constraint conflict in certain circumstances, The system automatically handles conflicts will power level lower constraint give up, Because of not clear every constraint should be at the right level., Often there will be the occasional problem (such as vertical screen case constraint no problem, Cross screen come after he found a label a control's don't be careful not to delete the specified width constraint, Cause constraint conflict control and control of deformation within the label, And then trigger a series of chain reaction)

Of course, use Xib to define the viewcontroller also have access to constraint, and each requires a management and specify (default constraint often lead to conflict)



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Charles at November 22, 2013 - 2:11 AM