IOS xib using Uiscrollview settings contentsize invalid

Source: Internet
Author: User

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

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.