/ * Say a few words about AutoLayout
* When there are AutoLayout and autoresize child controls within a control, the parts to be fitted autoresize
* translatesautoresizingmaskintoconstraints default is to open the converted
The size of the AutoLayout view can be calculated using the following code under AutoResize
if (!contentview.translatesautoresizingmaskintoconstraints) {
[Contentview needsupdateconstraints];
[Contentview updateconstraints];
cgsize ss = [Contentview systemlayoutsizefittingsize:uilayoutfittingcompressedsize];
}
In addition, if the AutoLayout view is inside the autoresize view and you need to configure a relative position, you can use the following code to set
[Autoresizeview removeconstraints:autoresizeview.constraints];//or just delete the configuration content-related
nsdictionary *dic = nsdictionaryofvariablebindings (AutoLayout);
nsstring *VFL = [NSString stringwithformat:@ "V:|-%f-[autolayout]", RECT.ORIGIN.Y];
Nsarray *ar = [nslayoutconstraint constraintswithvisualformat:vfl options:0 metrics:nil views:dic];
[Autoresizeview Addconstraints:ar];
VFL = [NSString stringwithformat:@ "|-%f-[autolayout]", rect.origin.x];
AR = [nslayoutconstraint constraintswithvisualformat:vfl options:0 metrics:nil views:dic];
[Autoresizeview Addconstraints:ar];
*/
There is another way to calculate outside, add a uiview shell to the AutoLayout view,systemlayoutsizefittingsize: calculate the size set to the shell, and put it on a non-AutoLayout supported view
Workarounds for iOS automatic layout and non-automatic layout nesting