how do I use UIScrollView in Interface Builder?

后端 未结 17 1404
遇见更好的自我
遇见更好的自我 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:13

    Now there is a way to make a UIScrollView scroll without leaving Storyboard:

    1. Select the UIScrollView in the Storyboard, go to the Size inspector and change the Bottom value (or whatever other value you need to change) in the Content Insets section to the height of the content area.
    2. Now go to the Identity inspector and create a new User Defined Runtime Attribute (by clicking the + button) and name it contentSize. It doesn't matter what Type or Value you fill in (you can even leave their default value).

    This will make the UIScrollView work properly, although I don't know why the second step is necessary (I found out by chance). :(

提交回复
热议问题