How can I use Autolayout to set constraints on my UIScrollview?

后端 未结 18 1691
别那么骄傲
别那么骄傲 2020-11-28 00:43

I have spent two days trying out the various solutions for Mixed and Pure Autolayout approaches to achieve what was a trivial scrollview setup prior to autolayout, and it\'s

18条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 01:44

    LOL welcome to the stupidity club. I'm one of the founders. :D

    For VERTICAL scrolling: the only way I could get it to work (iOS 8, Xcode 6 and pure autolayout) was adding the following constraints to my Scroll View (all related to the superview):

    • Equal Widths
    • Equal Heights
    • Center Y Alignment
    • Center X Alignment

    My structure:

      UIView
       - ScrollView
        - Subview
        - Subview
        - Subview
        - Subview
        - ...
    

    This is the final result:

    Demo

    This is the setup:

    Setup Full screen

    And here is the project.

    Hopefully this would save someone from GOING TO SLEEP AT 5 AM. :D

提交回复
热议问题