how do I use UIScrollView in Interface Builder?

后端 未结 17 1422
遇见更好的自我
遇见更好的自我 2020-11-28 19:52

While I\'ve used UIScrollView successfully in the past by manipulating it programmatically, I\'m having trouble getting it to work by setting it up exclusively

17条回答
  •  日久生厌
    2020-11-28 20:06

    You can have UIScrollView in StoryBoard with Autolayouts. Basically what do you need is:

    1. Add UIScrollView
    2. Add all constraints to it (like insets from top, left, right, bottom edges)
    3. Add a 'container' UIView to UIScrollView
    4. If you want just one-direction scroll (say, vertical): set height explicitly (for the instance, 600) and link width to the width of UIScrollView.
    5. If you want two-directional scroll just set both width and height.

    storyboard setup

提交回复
热议问题