A description of the problem
Today to do a demand, the background to obtain multiple object information, if an object is nil, it will not be displayed, when there are multiple return objects to fit, the interface can not accommodate all the elements, nonsense so much, in short, is used in Xib Uiscrollview, But the problem is that the. m file is set contentsize invalid.
Two problems analysis
The AutoLayout option is checked in xib, and the mechanism for iOS to calculate Uiscrollview contentsize is slightly different under AutoLayout. In AutoLayout, Uiscrollview is recalculated based on the constraint of Subview before viewdidappear. When Contentsize is manually set in Viewdidload, it is recalculated again, overwriting the previously set values manually.
Three-way solution2.1Remove the AutoLayout option and manually set the contentsize yourself2.2 If you want to use AutoLayout, you need to set Subview constraint, so that the system automatically calculates contentsize based on constraint2.3manually set the contentsize inside the viewdidappear.
IOS xib using Uiscrollview settings contentsize invalid